[PATCH] D114319: [InstrProf][NFC] Save profile bias to function map
Ellis Hoag via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 22 10:27:20 PST 2021
ellis updated this revision to Diff 388968.
ellis added a comment.
Rebase.
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
@@ -700,10 +700,9 @@
Type *Int64Ty = Type::getInt64Ty(M->getContext());
Type *Int64PtrTy = Type::getInt64PtrTy(M->getContext());
Function *Fn = Inc->getParent()->getParent();
- Instruction &I = Fn->getEntryBlock().front();
- LoadInst *LI = dyn_cast<LoadInst>(&I);
- if (!LI) {
- IRBuilder<> Builder(&I);
+ auto *&BiasLI = FunctionToProfileBiasLI[Fn];
+ if (!BiasLI) {
+ IRBuilder<> Builder(&Fn->getEntryBlock().front());
GlobalVariable *Bias =
M->getGlobalVariable(getInstrProfCounterBiasVarName());
if (!Bias) {
@@ -721,9 +720,10 @@
if (TT.supportsCOMDAT())
Bias->setComdat(M->getOrInsertComdat(Bias->getName()));
}
- LI = Builder.CreateLoad(Int64Ty, Bias);
+ BiasLI = Builder.CreateLoad(Int64Ty, Bias);
}
- auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), LI);
+ auto *Add =
+ Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), BiasLI);
Addr = Builder.CreateIntToPtr(Add, Int64PtrTy);
}
Index: llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
===================================================================
--- llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -57,6 +57,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 *> FunctionToProfileBiasLI;
std::vector<GlobalValue *> CompilerUsedVars;
std::vector<GlobalValue *> UsedVars;
std::vector<GlobalVariable *> ReferencedNames;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114319.388968.patch
Type: text/x-patch
Size: 2003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211122/4d1ad444/attachment.bin>
More information about the llvm-commits
mailing list