[PATCH] D114319: [InstrProf][NFC] Save profile bias to function map
Ellis Hoag via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 08:32:48 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e23cd2bf073: [InstrProf][NFC] Save profile bias to function map (authored by ellis).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114319/new/
https://reviews.llvm.org/D114319
Files:
llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -703,10 +703,9 @@
Type *Int64Ty = Type::getInt64Ty(M->getContext());
Function *Fn = I->getParent()->getParent();
- Instruction &EntryI = Fn->getEntryBlock().front();
- LoadInst *LI = dyn_cast<LoadInst>(&EntryI);
- if (!LI) {
- IRBuilder<> EntryBuilder(&EntryI);
+ LoadInst *&BiasLI = FunctionToProfileBiasMap[Fn];
+ if (!BiasLI) {
+ IRBuilder<> EntryBuilder(&Fn->getEntryBlock().front());
auto *Bias = M->getGlobalVariable(getInstrProfCounterBiasVarName());
if (!Bias) {
// Compiler must define this variable when runtime counter relocation
@@ -723,9 +722,9 @@
if (TT.supportsCOMDAT())
Bias->setComdat(M->getOrInsertComdat(Bias->getName()));
}
- LI = EntryBuilder.CreateLoad(Int64Ty, Bias);
+ BiasLI = EntryBuilder.CreateLoad(Int64Ty, Bias);
}
- auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), LI);
+ auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), BiasLI);
return Builder.CreateIntToPtr(Add, Addr->getType());
}
Index: llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
===================================================================
--- llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -56,6 +56,9 @@
}
};
DenseMap<GlobalVariable *, PerFunctionProfileData> ProfileDataMap;
+ /// If runtime relocation is enabled, this maps functions to the load
+ /// instruction that produces the profile relocation bias.
+ DenseMap<const Function *, LoadInst *> FunctionToProfileBiasMap;
std::vector<GlobalValue *> CompilerUsedVars;
std::vector<GlobalValue *> UsedVars;
std::vector<GlobalVariable *> ReferencedNames;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114319.429725.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/5179b465/attachment.bin>
More information about the llvm-commits
mailing list