2016-04-11 21:58:45 +08:00
|
|
|
//===- ModuleSummaryAnalysis.cpp - Module summary index builder -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This pass builds a ModuleSummaryIndex object for the module, to be written
|
|
|
|
// to bitcode or LLVM assembly.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
|
2016-12-21 05:12:28 +08:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
|
|
|
#include "llvm/ADT/SetVector.h"
|
2016-11-15 01:12:32 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2016-04-11 21:58:45 +08:00
|
|
|
#include "llvm/Analysis/BlockFrequencyInfo.h"
|
|
|
|
#include "llvm/Analysis/BlockFrequencyInfoImpl.h"
|
|
|
|
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
2016-07-17 22:47:01 +08:00
|
|
|
#include "llvm/Analysis/IndirectCallPromotionAnalysis.h"
|
2016-04-11 21:58:45 +08:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
#include "llvm/Analysis/ProfileSummaryInfo.h"
|
2016-12-22 07:03:45 +08:00
|
|
|
#include "llvm/Analysis/TypeMetadataUtils.h"
|
2016-04-11 21:58:45 +08:00
|
|
|
#include "llvm/IR/CallSite.h"
|
|
|
|
#include "llvm/IR/Dominators.h"
|
2016-04-27 22:19:38 +08:00
|
|
|
#include "llvm/IR/InstIterator.h"
|
2016-04-11 21:58:45 +08:00
|
|
|
#include "llvm/IR/IntrinsicInst.h"
|
|
|
|
#include "llvm/IR/ValueSymbolTable.h"
|
2017-03-31 08:08:24 +08:00
|
|
|
#include "llvm/Object/ModuleSymbolTable.h"
|
2016-04-11 21:58:45 +08:00
|
|
|
#include "llvm/Pass.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "module-summary-analysis"
|
|
|
|
|
|
|
|
// Walk through the operands of a given User via worklist iteration and populate
|
|
|
|
// the set of GlobalValue references encountered. Invoked either on an
|
|
|
|
// Instruction or a GlobalVariable (which walks its initializer).
|
2017-05-05 02:03:25 +08:00
|
|
|
static void findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
|
|
|
|
SetVector<ValueInfo> &RefEdges,
|
2016-04-11 21:58:45 +08:00
|
|
|
SmallPtrSet<const User *, 8> &Visited) {
|
|
|
|
SmallVector<const User *, 32> Worklist;
|
|
|
|
Worklist.push_back(CurUser);
|
|
|
|
|
|
|
|
while (!Worklist.empty()) {
|
|
|
|
const User *U = Worklist.pop_back_val();
|
|
|
|
|
|
|
|
if (!Visited.insert(U).second)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ImmutableCallSite CS(U);
|
|
|
|
|
|
|
|
for (const auto &OI : U->operands()) {
|
|
|
|
const User *Operand = dyn_cast<User>(OI);
|
|
|
|
if (!Operand)
|
|
|
|
continue;
|
|
|
|
if (isa<BlockAddress>(Operand))
|
|
|
|
continue;
|
2016-12-21 05:12:28 +08:00
|
|
|
if (auto *GV = dyn_cast<GlobalValue>(Operand)) {
|
2016-04-11 21:58:45 +08:00
|
|
|
// We have a reference to a global value. This should be added to
|
|
|
|
// the reference set unless it is a callee. Callees are handled
|
|
|
|
// specially by WriteFunction and are added to a separate list.
|
|
|
|
if (!(CS && CS.isCallee(&OI)))
|
2017-05-05 02:03:25 +08:00
|
|
|
RefEdges.insert(Index.getOrInsertValueInfo(GV));
|
2016-04-11 21:58:45 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Worklist.push_back(Operand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
static CalleeInfo::HotnessType getHotness(uint64_t ProfileCount,
|
|
|
|
ProfileSummaryInfo *PSI) {
|
|
|
|
if (!PSI)
|
|
|
|
return CalleeInfo::HotnessType::Unknown;
|
|
|
|
if (PSI->isHotCount(ProfileCount))
|
|
|
|
return CalleeInfo::HotnessType::Hot;
|
|
|
|
if (PSI->isColdCount(ProfileCount))
|
|
|
|
return CalleeInfo::HotnessType::Cold;
|
|
|
|
return CalleeInfo::HotnessType::None;
|
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
static bool isNonRenamableLocal(const GlobalValue &GV) {
|
|
|
|
return GV.hasSection() && GV.hasLocalLinkage();
|
|
|
|
}
|
|
|
|
|
2017-02-11 06:29:38 +08:00
|
|
|
/// Determine whether this call has all constant integer arguments (excluding
|
|
|
|
/// "this") and summarize it to VCalls or ConstVCalls as appropriate.
|
|
|
|
static void addVCallToSet(DevirtCallSite Call, GlobalValue::GUID Guid,
|
|
|
|
SetVector<FunctionSummary::VFuncId> &VCalls,
|
|
|
|
SetVector<FunctionSummary::ConstVCall> &ConstVCalls) {
|
|
|
|
std::vector<uint64_t> Args;
|
|
|
|
// Start from the second argument to skip the "this" pointer.
|
|
|
|
for (auto &Arg : make_range(Call.CS.arg_begin() + 1, Call.CS.arg_end())) {
|
|
|
|
auto *CI = dyn_cast<ConstantInt>(Arg);
|
|
|
|
if (!CI || CI->getBitWidth() > 64) {
|
|
|
|
VCalls.insert({Guid, Call.Offset});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Args.push_back(CI->getZExtValue());
|
|
|
|
}
|
|
|
|
ConstVCalls.insert({{Guid, Call.Offset}, std::move(Args)});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// If this intrinsic call requires that we add information to the function
|
|
|
|
/// summary, do so via the non-constant reference arguments.
|
|
|
|
static void addIntrinsicToSummary(
|
|
|
|
const CallInst *CI, SetVector<GlobalValue::GUID> &TypeTests,
|
|
|
|
SetVector<FunctionSummary::VFuncId> &TypeTestAssumeVCalls,
|
|
|
|
SetVector<FunctionSummary::VFuncId> &TypeCheckedLoadVCalls,
|
|
|
|
SetVector<FunctionSummary::ConstVCall> &TypeTestAssumeConstVCalls,
|
|
|
|
SetVector<FunctionSummary::ConstVCall> &TypeCheckedLoadConstVCalls) {
|
|
|
|
switch (CI->getCalledFunction()->getIntrinsicID()) {
|
|
|
|
case Intrinsic::type_test: {
|
|
|
|
auto *TypeMDVal = cast<MetadataAsValue>(CI->getArgOperand(1));
|
|
|
|
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
|
|
|
|
if (!TypeId)
|
|
|
|
break;
|
|
|
|
GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
|
|
|
|
|
|
|
|
// Produce a summary from type.test intrinsics. We only summarize type.test
|
|
|
|
// intrinsics that are used other than by an llvm.assume intrinsic.
|
|
|
|
// Intrinsics that are assumed are relevant only to the devirtualization
|
|
|
|
// pass, not the type test lowering pass.
|
|
|
|
bool HasNonAssumeUses = llvm::any_of(CI->uses(), [](const Use &CIU) {
|
|
|
|
auto *AssumeCI = dyn_cast<CallInst>(CIU.getUser());
|
|
|
|
if (!AssumeCI)
|
|
|
|
return true;
|
|
|
|
Function *F = AssumeCI->getCalledFunction();
|
|
|
|
return !F || F->getIntrinsicID() != Intrinsic::assume;
|
|
|
|
});
|
|
|
|
if (HasNonAssumeUses)
|
|
|
|
TypeTests.insert(Guid);
|
|
|
|
|
|
|
|
SmallVector<DevirtCallSite, 4> DevirtCalls;
|
|
|
|
SmallVector<CallInst *, 4> Assumes;
|
|
|
|
findDevirtualizableCallsForTypeTest(DevirtCalls, Assumes, CI);
|
|
|
|
for (auto &Call : DevirtCalls)
|
|
|
|
addVCallToSet(Call, Guid, TypeTestAssumeVCalls,
|
|
|
|
TypeTestAssumeConstVCalls);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Intrinsic::type_checked_load: {
|
|
|
|
auto *TypeMDVal = cast<MetadataAsValue>(CI->getArgOperand(2));
|
|
|
|
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
|
|
|
|
if (!TypeId)
|
|
|
|
break;
|
|
|
|
GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
|
|
|
|
|
|
|
|
SmallVector<DevirtCallSite, 4> DevirtCalls;
|
|
|
|
SmallVector<Instruction *, 4> LoadedPtrs;
|
|
|
|
SmallVector<Instruction *, 4> Preds;
|
|
|
|
bool HasNonCallUses = false;
|
|
|
|
findDevirtualizableCallsForTypeCheckedLoad(DevirtCalls, LoadedPtrs, Preds,
|
|
|
|
HasNonCallUses, CI);
|
|
|
|
// Any non-call uses of the result of llvm.type.checked.load will
|
|
|
|
// prevent us from optimizing away the llvm.type.test.
|
|
|
|
if (HasNonCallUses)
|
|
|
|
TypeTests.insert(Guid);
|
|
|
|
for (auto &Call : DevirtCalls)
|
|
|
|
addVCallToSet(Call, Guid, TypeCheckedLoadVCalls,
|
|
|
|
TypeCheckedLoadConstVCalls);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
static void
|
|
|
|
computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M,
|
|
|
|
const Function &F, BlockFrequencyInfo *BFI,
|
|
|
|
ProfileSummaryInfo *PSI, bool HasLocalsInUsed,
|
2017-01-05 22:59:56 +08:00
|
|
|
DenseSet<GlobalValue::GUID> &CantBePromoted) {
|
2016-10-28 10:39:38 +08:00
|
|
|
// Summary not currently supported for anonymous functions, they should
|
|
|
|
// have been named.
|
|
|
|
assert(F.hasName());
|
2016-04-11 21:58:45 +08:00
|
|
|
|
|
|
|
unsigned NumInsts = 0;
|
|
|
|
// Map from callee ValueId to profile count. Used to accumulate profile
|
|
|
|
// counts for all static calls to a given callee.
|
2016-12-21 05:12:28 +08:00
|
|
|
MapVector<ValueInfo, CalleeInfo> CallGraphEdges;
|
|
|
|
SetVector<ValueInfo> RefEdges;
|
2016-12-22 07:03:45 +08:00
|
|
|
SetVector<GlobalValue::GUID> TypeTests;
|
2017-02-11 06:29:38 +08:00
|
|
|
SetVector<FunctionSummary::VFuncId> TypeTestAssumeVCalls,
|
|
|
|
TypeCheckedLoadVCalls;
|
|
|
|
SetVector<FunctionSummary::ConstVCall> TypeTestAssumeConstVCalls,
|
|
|
|
TypeCheckedLoadConstVCalls;
|
2016-07-17 22:47:01 +08:00
|
|
|
ICallPromotionAnalysis ICallAnalysis;
|
2016-04-11 21:58:45 +08:00
|
|
|
|
2016-11-15 00:40:19 +08:00
|
|
|
bool HasInlineAsmMaybeReferencingInternal = false;
|
2016-04-11 21:58:45 +08:00
|
|
|
SmallPtrSet<const User *, 8> Visited;
|
2016-06-27 01:27:42 +08:00
|
|
|
for (const BasicBlock &BB : F)
|
|
|
|
for (const Instruction &I : BB) {
|
2016-08-30 08:46:26 +08:00
|
|
|
if (isa<DbgInfoIntrinsic>(I))
|
|
|
|
continue;
|
|
|
|
++NumInsts;
|
2017-05-05 02:03:25 +08:00
|
|
|
findRefEdges(Index, &I, RefEdges, Visited);
|
2016-08-30 08:46:26 +08:00
|
|
|
auto CS = ImmutableCallSite(&I);
|
|
|
|
if (!CS)
|
|
|
|
continue;
|
2016-10-30 13:40:44 +08:00
|
|
|
|
|
|
|
const auto *CI = dyn_cast<CallInst>(&I);
|
|
|
|
// Since we don't know exactly which local values are referenced in inline
|
2016-11-15 00:40:19 +08:00
|
|
|
// assembly, conservatively mark the function as possibly referencing
|
|
|
|
// a local value from inline assembly to ensure we don't export a
|
|
|
|
// reference (which would require renaming and promotion of the
|
|
|
|
// referenced value).
|
2016-10-30 13:40:44 +08:00
|
|
|
if (HasLocalsInUsed && CI && CI->isInlineAsm())
|
2016-11-15 00:40:19 +08:00
|
|
|
HasInlineAsmMaybeReferencingInternal = true;
|
2016-10-30 13:40:44 +08:00
|
|
|
|
2016-10-09 00:11:42 +08:00
|
|
|
auto *CalledValue = CS.getCalledValue();
|
2016-08-30 08:46:26 +08:00
|
|
|
auto *CalledFunction = CS.getCalledFunction();
|
2016-10-09 00:11:42 +08:00
|
|
|
// Check if this is an alias to a function. If so, get the
|
|
|
|
// called aliasee for the checks below.
|
|
|
|
if (auto *GA = dyn_cast<GlobalAlias>(CalledValue)) {
|
|
|
|
assert(!CalledFunction && "Expected null called function in callsite for alias");
|
|
|
|
CalledFunction = dyn_cast<Function>(GA->getBaseObject());
|
|
|
|
}
|
2016-12-22 07:03:45 +08:00
|
|
|
// Check if this is a direct call to a known function or a known
|
|
|
|
// intrinsic, or an indirect call with profile data.
|
2016-08-30 08:46:26 +08:00
|
|
|
if (CalledFunction) {
|
2017-02-11 06:29:38 +08:00
|
|
|
if (CI && CalledFunction->isIntrinsic()) {
|
|
|
|
addIntrinsicToSummary(
|
|
|
|
CI, TypeTests, TypeTestAssumeVCalls, TypeCheckedLoadVCalls,
|
|
|
|
TypeTestAssumeConstVCalls, TypeCheckedLoadConstVCalls);
|
|
|
|
continue;
|
2016-12-22 07:03:45 +08:00
|
|
|
}
|
2016-10-28 10:39:38 +08:00
|
|
|
// We should have named any anonymous globals
|
|
|
|
assert(CalledFunction->hasName());
|
2017-05-10 07:21:10 +08:00
|
|
|
auto ScaledCount = PSI->getProfileCount(&I, BFI);
|
2016-12-21 05:12:28 +08:00
|
|
|
auto Hotness = ScaledCount ? getHotness(ScaledCount.getValue(), PSI)
|
|
|
|
: CalleeInfo::HotnessType::Unknown;
|
|
|
|
|
2016-10-09 00:11:42 +08:00
|
|
|
// Use the original CalledValue, in case it was an alias. We want
|
|
|
|
// to record the call edge to the alias in that case. Eventually
|
|
|
|
// an alias summary will be created to associate the alias and
|
|
|
|
// aliasee.
|
2017-05-05 02:03:25 +08:00
|
|
|
CallGraphEdges[Index.getOrInsertValueInfo(
|
|
|
|
cast<GlobalValue>(CalledValue))]
|
|
|
|
.updateHotness(Hotness);
|
2016-08-30 08:46:26 +08:00
|
|
|
} else {
|
|
|
|
// Skip inline assembly calls.
|
|
|
|
if (CI && CI->isInlineAsm())
|
|
|
|
continue;
|
|
|
|
// Skip direct calls.
|
|
|
|
if (!CS.getCalledValue() || isa<Constant>(CS.getCalledValue()))
|
|
|
|
continue;
|
2016-04-11 21:58:45 +08:00
|
|
|
|
2016-08-30 08:46:26 +08:00
|
|
|
uint32_t NumVals, NumCandidates;
|
|
|
|
uint64_t TotalCount;
|
|
|
|
auto CandidateProfileData =
|
|
|
|
ICallAnalysis.getPromotionCandidatesForInstruction(
|
|
|
|
&I, NumVals, TotalCount, NumCandidates);
|
|
|
|
for (auto &Candidate : CandidateProfileData)
|
2017-05-05 02:03:25 +08:00
|
|
|
CallGraphEdges[Index.getOrInsertValueInfo(Candidate.Value)]
|
|
|
|
.updateHotness(getHotness(Candidate.Count, PSI));
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-01 02:09:44 +08:00
|
|
|
// Explicit add hot edges to enforce importing for designated GUIDs for
|
|
|
|
// sample PGO, to enable the same inlines as the profiled optimized binary.
|
|
|
|
for (auto &I : F.getImportGUIDs())
|
2017-05-05 02:03:25 +08:00
|
|
|
CallGraphEdges[Index.getOrInsertValueInfo(I)].updateHotness(
|
2017-07-08 05:01:00 +08:00
|
|
|
CalleeInfo::HotnessType::Critical);
|
2017-03-01 02:09:44 +08:00
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
bool NonRenamableLocal = isNonRenamableLocal(F);
|
|
|
|
bool NotEligibleForImport =
|
|
|
|
NonRenamableLocal || HasInlineAsmMaybeReferencingInternal ||
|
|
|
|
// Inliner doesn't handle variadic functions.
|
|
|
|
// FIXME: refactor this to use the same code that inliner is using.
|
|
|
|
F.isVarArg();
|
2017-01-06 05:34:18 +08:00
|
|
|
GlobalValueSummary::GVFlags Flags(F.getLinkage(), NotEligibleForImport,
|
2017-06-02 04:30:06 +08:00
|
|
|
/* Live = */ false);
|
2017-08-05 00:00:58 +08:00
|
|
|
FunctionSummary::FFlags FunFlags{
|
|
|
|
F.hasFnAttribute(Attribute::ReadNone),
|
|
|
|
F.hasFnAttribute(Attribute::ReadOnly),
|
|
|
|
F.hasFnAttribute(Attribute::NoRecurse),
|
|
|
|
F.returnDoesNotAlias(),
|
|
|
|
};
|
2016-12-21 05:12:28 +08:00
|
|
|
auto FuncSummary = llvm::make_unique<FunctionSummary>(
|
2017-08-05 00:00:58 +08:00
|
|
|
Flags, NumInsts, FunFlags, RefEdges.takeVector(),
|
|
|
|
CallGraphEdges.takeVector(), TypeTests.takeVector(),
|
|
|
|
TypeTestAssumeVCalls.takeVector(), TypeCheckedLoadVCalls.takeVector(),
|
2017-02-11 06:29:38 +08:00
|
|
|
TypeTestAssumeConstVCalls.takeVector(),
|
|
|
|
TypeCheckedLoadConstVCalls.takeVector());
|
2017-01-05 22:32:16 +08:00
|
|
|
if (NonRenamableLocal)
|
|
|
|
CantBePromoted.insert(F.getGUID());
|
2016-08-19 15:49:19 +08:00
|
|
|
Index.addGlobalValueSummary(F.getName(), std::move(FuncSummary));
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
static void
|
|
|
|
computeVariableSummary(ModuleSummaryIndex &Index, const GlobalVariable &V,
|
2017-01-05 22:59:56 +08:00
|
|
|
DenseSet<GlobalValue::GUID> &CantBePromoted) {
|
2016-12-21 05:12:28 +08:00
|
|
|
SetVector<ValueInfo> RefEdges;
|
2016-04-11 21:58:45 +08:00
|
|
|
SmallPtrSet<const User *, 8> Visited;
|
2017-05-05 02:03:25 +08:00
|
|
|
findRefEdges(Index, &V, RefEdges, Visited);
|
2017-01-05 22:32:16 +08:00
|
|
|
bool NonRenamableLocal = isNonRenamableLocal(V);
|
2017-01-06 05:34:18 +08:00
|
|
|
GlobalValueSummary::GVFlags Flags(V.getLinkage(), NonRenamableLocal,
|
2017-06-02 04:30:06 +08:00
|
|
|
/* Live = */ false);
|
2016-12-21 05:12:28 +08:00
|
|
|
auto GVarSummary =
|
|
|
|
llvm::make_unique<GlobalVarSummary>(Flags, RefEdges.takeVector());
|
2017-01-05 22:32:16 +08:00
|
|
|
if (NonRenamableLocal)
|
|
|
|
CantBePromoted.insert(V.getGUID());
|
2016-08-19 15:49:19 +08:00
|
|
|
Index.addGlobalValueSummary(V.getName(), std::move(GVarSummary));
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
static void
|
|
|
|
computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
|
2017-01-05 22:59:56 +08:00
|
|
|
DenseSet<GlobalValue::GUID> &CantBePromoted) {
|
2017-01-05 22:32:16 +08:00
|
|
|
bool NonRenamableLocal = isNonRenamableLocal(A);
|
2017-01-06 05:34:18 +08:00
|
|
|
GlobalValueSummary::GVFlags Flags(A.getLinkage(), NonRenamableLocal,
|
2017-06-02 04:30:06 +08:00
|
|
|
/* Live = */ false);
|
2016-12-21 05:12:28 +08:00
|
|
|
auto AS = llvm::make_unique<AliasSummary>(Flags, ArrayRef<ValueInfo>{});
|
2016-10-28 10:39:38 +08:00
|
|
|
auto *Aliasee = A.getBaseObject();
|
|
|
|
auto *AliaseeSummary = Index.getGlobalValueSummary(*Aliasee);
|
|
|
|
assert(AliaseeSummary && "Alias expects aliasee summary to be parsed");
|
|
|
|
AS->setAliasee(AliaseeSummary);
|
2017-01-05 22:32:16 +08:00
|
|
|
if (NonRenamableLocal)
|
|
|
|
CantBePromoted.insert(A.getGUID());
|
2016-10-28 10:39:38 +08:00
|
|
|
Index.addGlobalValueSummary(A.getName(), std::move(AS));
|
|
|
|
}
|
|
|
|
|
2017-01-06 05:34:18 +08:00
|
|
|
// Set LiveRoot flag on entries matching the given value name.
|
|
|
|
static void setLiveRoot(ModuleSummaryIndex &Index, StringRef Name) {
|
2017-05-05 02:03:25 +08:00
|
|
|
if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID(Name)))
|
|
|
|
for (auto &Summary : VI.getSummaryList())
|
2017-06-02 04:30:06 +08:00
|
|
|
Summary->setLive(true);
|
2017-01-06 05:34:18 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 15:49:19 +08:00
|
|
|
ModuleSummaryIndex llvm::buildModuleSummaryIndex(
|
|
|
|
const Module &M,
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback,
|
|
|
|
ProfileSummaryInfo *PSI) {
|
2017-05-11 02:52:16 +08:00
|
|
|
assert(PSI);
|
2016-08-19 15:49:19 +08:00
|
|
|
ModuleSummaryIndex Index;
|
2016-10-30 13:40:44 +08:00
|
|
|
|
2016-11-11 00:57:32 +08:00
|
|
|
// Identify the local values in the llvm.used and llvm.compiler.used sets,
|
|
|
|
// which should not be exported as they would then require renaming and
|
|
|
|
// promotion, but we may have opaque uses e.g. in inline asm. We collect them
|
|
|
|
// here because we use this information to mark functions containing inline
|
|
|
|
// assembly calls as not importable.
|
|
|
|
SmallPtrSet<GlobalValue *, 8> LocalsUsed;
|
2016-10-30 13:40:44 +08:00
|
|
|
SmallPtrSet<GlobalValue *, 8> Used;
|
2016-11-11 00:57:32 +08:00
|
|
|
// First collect those in the llvm.used set.
|
2016-10-30 13:40:44 +08:00
|
|
|
collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false);
|
2016-11-11 00:57:32 +08:00
|
|
|
// Next collect those in the llvm.compiler.used set.
|
|
|
|
collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ true);
|
2017-01-05 22:59:56 +08:00
|
|
|
DenseSet<GlobalValue::GUID> CantBePromoted;
|
2016-10-30 13:40:44 +08:00
|
|
|
for (auto *V : Used) {
|
2017-01-05 22:32:16 +08:00
|
|
|
if (V->hasLocalLinkage()) {
|
2016-10-30 13:40:44 +08:00
|
|
|
LocalsUsed.insert(V);
|
2017-01-05 22:32:16 +08:00
|
|
|
CantBePromoted.insert(V->getGUID());
|
|
|
|
}
|
2016-10-30 13:40:44 +08:00
|
|
|
}
|
2016-04-20 22:39:45 +08:00
|
|
|
|
2016-04-11 21:58:45 +08:00
|
|
|
// Compute summaries for all functions defined in module, and save in the
|
|
|
|
// index.
|
2016-08-19 15:49:19 +08:00
|
|
|
for (auto &F : M) {
|
2016-04-11 21:58:45 +08:00
|
|
|
if (F.isDeclaration())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BlockFrequencyInfo *BFI = nullptr;
|
|
|
|
std::unique_ptr<BlockFrequencyInfo> BFIPtr;
|
2016-08-19 15:49:19 +08:00
|
|
|
if (GetBFICallback)
|
|
|
|
BFI = GetBFICallback(F);
|
2016-04-11 21:58:45 +08:00
|
|
|
else if (F.getEntryCount().hasValue()) {
|
|
|
|
LoopInfo LI{DominatorTree(const_cast<Function &>(F))};
|
|
|
|
BranchProbabilityInfo BPI{F, LI};
|
|
|
|
BFIPtr = llvm::make_unique<BlockFrequencyInfo>(F, BPI, LI);
|
|
|
|
BFI = BFIPtr.get();
|
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
computeFunctionSummary(Index, M, F, BFI, PSI, !LocalsUsed.empty(),
|
|
|
|
CantBePromoted);
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compute summaries for all variables defined in module, and save in the
|
|
|
|
// index.
|
2016-08-19 15:49:19 +08:00
|
|
|
for (const GlobalVariable &G : M.globals()) {
|
2016-04-11 21:58:45 +08:00
|
|
|
if (G.isDeclaration())
|
|
|
|
continue;
|
2017-01-05 22:32:16 +08:00
|
|
|
computeVariableSummary(Index, G, CantBePromoted);
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
2016-10-28 10:39:38 +08:00
|
|
|
|
|
|
|
// Compute summaries for all aliases defined in module, and save in the
|
|
|
|
// index.
|
|
|
|
for (const GlobalAlias &A : M.aliases())
|
2017-01-05 22:32:16 +08:00
|
|
|
computeAliasSummary(Index, A, CantBePromoted);
|
2016-10-28 10:39:38 +08:00
|
|
|
|
2016-10-30 13:40:44 +08:00
|
|
|
for (auto *V : LocalsUsed) {
|
|
|
|
auto *Summary = Index.getGlobalValueSummary(*V);
|
|
|
|
assert(Summary && "Missing summary for global value");
|
2017-01-05 22:32:16 +08:00
|
|
|
Summary->setNotEligibleToImport();
|
2016-10-30 13:40:44 +08:00
|
|
|
}
|
|
|
|
|
2017-01-06 05:34:18 +08:00
|
|
|
// The linker doesn't know about these LLVM produced values, so we need
|
|
|
|
// to flag them as live in the index to ensure index-based dead value
|
|
|
|
// analysis treats them as live roots of the analysis.
|
|
|
|
setLiveRoot(Index, "llvm.used");
|
|
|
|
setLiveRoot(Index, "llvm.compiler.used");
|
|
|
|
setLiveRoot(Index, "llvm.global_ctors");
|
|
|
|
setLiveRoot(Index, "llvm.global_dtors");
|
|
|
|
setLiveRoot(Index, "llvm.global.annotations");
|
|
|
|
|
2016-11-15 01:12:32 +08:00
|
|
|
if (!M.getModuleInlineAsm().empty()) {
|
|
|
|
// Collect the local values defined by module level asm, and set up
|
|
|
|
// summaries for these symbols so that they can be marked as NoRename,
|
|
|
|
// to prevent export of any use of them in regular IR that would require
|
|
|
|
// renaming within the module level asm. Note we don't need to create a
|
|
|
|
// summary for weak or global defs, as they don't need to be flagged as
|
|
|
|
// NoRename, and defs in module level asm can't be imported anyway.
|
|
|
|
// Also, any values used but not defined within module level asm should
|
|
|
|
// be listed on the llvm.used or llvm.compiler.used global and marked as
|
|
|
|
// referenced from there.
|
2016-12-01 14:51:47 +08:00
|
|
|
ModuleSymbolTable::CollectAsmSymbols(
|
Perform symbol binding for .symver versioned symbols
Summary:
In a .symver assembler directive like:
.symver name, name2@@nodename
"name2@@nodename" should get the same symbol binding as "name".
While the ELF object writer is updating the symbol binding for .symver
aliases before emitting the object file, not doing so when the module
inline assembly is handled by the RecordStreamer is causing the wrong
behavior in *LTO mode.
E.g. when "name" is global, "name2@@nodename" must also be marked as
global. Otherwise, the symbol is skipped when iterating over the LTO
InputFile symbols (InputFile::Symbol::shouldSkip). So, for example,
when performing any *LTO via the gold-plugin, the versioned symbol
definition is not recorded by the plugin and passed back to the
linker. If the object was in an archive, and there were no other symbols
needed from that object, the object would not be included in the final
link and references to the versioned symbol are undefined.
The llvm-lto2 tests added will give an error about an unused symbol
resolution without the fix.
Reviewers: rafael, pcc
Reviewed By: pcc
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D30485
llvm-svn: 297332
2017-03-09 08:19:49 +08:00
|
|
|
M, [&M, &Index, &CantBePromoted](StringRef Name,
|
|
|
|
object::BasicSymbolRef::Flags Flags) {
|
2016-11-15 01:12:32 +08:00
|
|
|
// Symbols not marked as Weak or Global are local definitions.
|
2016-12-28 01:45:09 +08:00
|
|
|
if (Flags & (object::BasicSymbolRef::SF_Weak |
|
2016-11-15 01:12:32 +08:00
|
|
|
object::BasicSymbolRef::SF_Global))
|
|
|
|
return;
|
|
|
|
GlobalValue *GV = M.getNamedValue(Name);
|
|
|
|
if (!GV)
|
|
|
|
return;
|
|
|
|
assert(GV->isDeclaration() && "Def in module asm already has definition");
|
2017-01-05 22:32:16 +08:00
|
|
|
GlobalValueSummary::GVFlags GVFlags(GlobalValue::InternalLinkage,
|
2017-06-02 04:30:06 +08:00
|
|
|
/* NotEligibleToImport = */ true,
|
|
|
|
/* Live = */ true);
|
2017-01-05 22:32:16 +08:00
|
|
|
CantBePromoted.insert(GlobalValue::getGUID(Name));
|
2016-11-15 01:12:32 +08:00
|
|
|
// Create the appropriate summary type.
|
2017-08-05 00:00:58 +08:00
|
|
|
if (Function *F = dyn_cast<Function>(GV)) {
|
2016-11-15 01:12:32 +08:00
|
|
|
std::unique_ptr<FunctionSummary> Summary =
|
2016-12-21 05:12:28 +08:00
|
|
|
llvm::make_unique<FunctionSummary>(
|
2017-08-05 00:00:58 +08:00
|
|
|
GVFlags, 0,
|
|
|
|
FunctionSummary::FFlags{
|
|
|
|
F->hasFnAttribute(Attribute::ReadNone),
|
|
|
|
F->hasFnAttribute(Attribute::ReadOnly),
|
|
|
|
F->hasFnAttribute(Attribute::NoRecurse),
|
|
|
|
F->returnDoesNotAlias()},
|
|
|
|
ArrayRef<ValueInfo>{}, ArrayRef<FunctionSummary::EdgeTy>{},
|
2017-02-11 06:29:38 +08:00
|
|
|
ArrayRef<GlobalValue::GUID>{},
|
|
|
|
ArrayRef<FunctionSummary::VFuncId>{},
|
|
|
|
ArrayRef<FunctionSummary::VFuncId>{},
|
|
|
|
ArrayRef<FunctionSummary::ConstVCall>{},
|
|
|
|
ArrayRef<FunctionSummary::ConstVCall>{});
|
2016-11-15 01:12:32 +08:00
|
|
|
Index.addGlobalValueSummary(Name, std::move(Summary));
|
|
|
|
} else {
|
|
|
|
std::unique_ptr<GlobalVarSummary> Summary =
|
2016-12-21 05:12:28 +08:00
|
|
|
llvm::make_unique<GlobalVarSummary>(GVFlags,
|
|
|
|
ArrayRef<ValueInfo>{});
|
2016-11-15 01:12:32 +08:00
|
|
|
Index.addGlobalValueSummary(Name, std::move(Summary));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-09 07:01:49 +08:00
|
|
|
bool IsThinLTO = true;
|
|
|
|
if (auto *MD =
|
|
|
|
mdconst::extract_or_null<ConstantInt>(M.getModuleFlag("ThinLTO")))
|
|
|
|
IsThinLTO = MD->getZExtValue();
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
for (auto &GlobalList : Index) {
|
2017-05-05 02:03:25 +08:00
|
|
|
// Ignore entries for references that are undefined in the current module.
|
|
|
|
if (GlobalList.second.SummaryList.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
assert(GlobalList.second.SummaryList.size() == 1 &&
|
2017-01-05 22:32:16 +08:00
|
|
|
"Expected module's index to have one summary per GUID");
|
2017-05-05 02:03:25 +08:00
|
|
|
auto &Summary = GlobalList.second.SummaryList[0];
|
2017-06-09 07:01:49 +08:00
|
|
|
if (!IsThinLTO) {
|
|
|
|
Summary->setNotEligibleToImport();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-01-05 22:32:16 +08:00
|
|
|
bool AllRefsCanBeExternallyReferenced =
|
|
|
|
llvm::all_of(Summary->refs(), [&](const ValueInfo &VI) {
|
2017-05-05 02:03:25 +08:00
|
|
|
return !CantBePromoted.count(VI.getGUID());
|
2017-01-05 22:32:16 +08:00
|
|
|
});
|
|
|
|
if (!AllRefsCanBeExternallyReferenced) {
|
|
|
|
Summary->setNotEligibleToImport();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto *FuncSummary = dyn_cast<FunctionSummary>(Summary.get())) {
|
|
|
|
bool AllCallsCanBeExternallyReferenced = llvm::all_of(
|
|
|
|
FuncSummary->calls(), [&](const FunctionSummary::EdgeTy &Edge) {
|
2017-05-05 02:03:25 +08:00
|
|
|
return !CantBePromoted.count(Edge.first.getGUID());
|
2017-01-05 22:32:16 +08:00
|
|
|
});
|
|
|
|
if (!AllCallsCanBeExternallyReferenced)
|
|
|
|
Summary->setNotEligibleToImport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-19 15:49:19 +08:00
|
|
|
return Index;
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|
|
|
|
|
2016-11-24 01:53:26 +08:00
|
|
|
AnalysisKey ModuleSummaryIndexAnalysis::Key;
|
2016-08-12 21:53:02 +08:00
|
|
|
|
2016-08-19 15:49:19 +08:00
|
|
|
ModuleSummaryIndex
|
2016-08-12 21:53:02 +08:00
|
|
|
ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
ProfileSummaryInfo &PSI = AM.getResult<ProfileSummaryAnalysis>(M);
|
2016-08-12 21:53:02 +08:00
|
|
|
auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
return buildModuleSummaryIndex(
|
|
|
|
M,
|
|
|
|
[&FAM](const Function &F) {
|
|
|
|
return &FAM.getResult<BlockFrequencyAnalysis>(
|
|
|
|
*const_cast<Function *>(&F));
|
|
|
|
},
|
|
|
|
&PSI);
|
2016-08-12 21:53:02 +08:00
|
|
|
}
|
|
|
|
|
2016-04-11 21:58:45 +08:00
|
|
|
char ModuleSummaryIndexWrapperPass::ID = 0;
|
|
|
|
INITIALIZE_PASS_BEGIN(ModuleSummaryIndexWrapperPass, "module-summary-analysis",
|
|
|
|
"Module Summary Analysis", false, true)
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass)
|
2017-01-21 14:01:22 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)
|
2016-04-11 21:58:45 +08:00
|
|
|
INITIALIZE_PASS_END(ModuleSummaryIndexWrapperPass, "module-summary-analysis",
|
|
|
|
"Module Summary Analysis", false, true)
|
|
|
|
|
|
|
|
ModulePass *llvm::createModuleSummaryIndexWrapperPass() {
|
|
|
|
return new ModuleSummaryIndexWrapperPass();
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSummaryIndexWrapperPass::ModuleSummaryIndexWrapperPass()
|
|
|
|
: ModulePass(ID) {
|
|
|
|
initializeModuleSummaryIndexWrapperPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) {
|
2016-09-29 05:00:58 +08:00
|
|
|
auto &PSI = *getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
Index = buildModuleSummaryIndex(
|
|
|
|
M,
|
|
|
|
[this](const Function &F) {
|
|
|
|
return &(this->getAnalysis<BlockFrequencyInfoWrapperPass>(
|
|
|
|
*const_cast<Function *>(&F))
|
|
|
|
.getBFI());
|
|
|
|
},
|
|
|
|
&PSI);
|
2016-04-11 21:58:45 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ModuleSummaryIndexWrapperPass::doFinalization(Module &M) {
|
2016-08-19 15:49:19 +08:00
|
|
|
Index.reset();
|
2016-04-11 21:58:45 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModuleSummaryIndexWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
AU.addRequired<BlockFrequencyInfoWrapperPass>();
|
[thinlto] Basic thinlto fdo heuristic
Summary:
This patch improves thinlto importer
by importing 3x larger functions that are called from hot block.
I compared performance with the trunk on spec, and there
were about 2% on povray and 3.33% on milc. These results seems
to be consistant and match the results Teresa got with her simple
heuristic. Some benchmarks got slower but I think they are just
noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with
more iterations to confirm. Geomean of all benchmarks including the noisy ones
were about +0.02%.
I see much better improvement on google branch with Easwaran patch
for pgo callsite inlining (the inliner actually inline those big functions)
Over all I see +0.5% improvement, and I get +8.65% on povray.
So I guess we will see much bigger change when Easwaran patch will land
(it depends on new pass manager), but it is still worth putting this to trunk
before it.
Implementation details changes:
- Removed CallsiteCount.
- ProfileCount got replaced by Hotness
- hot-import-multiplier is set to 3.0 for now,
didn't have time to tune it up, but I see that we get most of the interesting
functions with 3, so there is no much performance difference with higher, and
binary size doesn't grow as much as with 10.0.
Reviewers: eraman, mehdi_amini, tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D24638
llvm-svn: 282437
2016-09-27 04:37:32 +08:00
|
|
|
AU.addRequired<ProfileSummaryInfoWrapperPass>();
|
2016-04-11 21:58:45 +08:00
|
|
|
}
|