[PATCH] D98187: [SamplePGO] Skip inlinee profile scaling for sample loader inlining
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 11 10:18:47 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG051f2c144e1e: [SamplePGO] Skip inlinee profile scaling for sample loader inlining (authored by wenlei).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98187/new/
https://reviews.llvm.org/D98187
Files:
llvm/include/llvm/Transforms/Utils/Cloning.h
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1954,13 +1954,19 @@
if (objcarc::hasAttachedCallOpBundle(&CB))
inlineRetainOrClaimRVCalls(CB, Returns);
- if (IFI.CallerBFI != nullptr && IFI.CalleeBFI != nullptr)
- // Update the BFI of blocks cloned into the caller.
- updateCallerBFI(OrigBB, VMap, IFI.CallerBFI, IFI.CalleeBFI,
- CalledFunc->front());
-
- updateCallProfile(CalledFunc, VMap, CalledFunc->getEntryCount(), CB,
- IFI.PSI, IFI.CallerBFI);
+ // Updated caller/callee profiles only when requested. For sample loader
+ // inlining, the context-sensitive inlinee profile doesn't need to be
+ // subtracted from callee profile, and the inlined clone also doesn't need
+ // to be scaled based on call site count.
+ if (IFI.UpdateProfile) {
+ if (IFI.CallerBFI != nullptr && IFI.CalleeBFI != nullptr)
+ // Update the BFI of blocks cloned into the caller.
+ updateCallerBFI(OrigBB, VMap, IFI.CallerBFI, IFI.CalleeBFI,
+ CalledFunc->front());
+
+ updateCallProfile(CalledFunc, VMap, CalledFunc->getEntryCount(), CB,
+ IFI.PSI, IFI.CallerBFI);
+ }
// Inject byval arguments initialization.
for (std::pair<Value*, Value*> &Init : ByValInit)
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1093,6 +1093,7 @@
return false;
InlineFunctionInfo IFI(nullptr, GetAC);
+ IFI.UpdateProfile = false;
if (InlineFunction(CB, IFI).isSuccess()) {
// The call to InlineFunction erases I, so we can't pass it here.
emitInlinedInto(*ORE, DLoc, BB, *CalledFunction, *BB->getParent(), Cost,
Index: llvm/include/llvm/Transforms/Utils/Cloning.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/Cloning.h
+++ llvm/include/llvm/Transforms/Utils/Cloning.h
@@ -197,9 +197,10 @@
function_ref<AssumptionCache &(Function &)> GetAssumptionCache = nullptr,
ProfileSummaryInfo *PSI = nullptr,
BlockFrequencyInfo *CallerBFI = nullptr,
- BlockFrequencyInfo *CalleeBFI = nullptr)
+ BlockFrequencyInfo *CalleeBFI = nullptr, bool UpdateProfile = true)
: CG(cg), GetAssumptionCache(GetAssumptionCache), PSI(PSI),
- CallerBFI(CallerBFI), CalleeBFI(CalleeBFI) {}
+ CallerBFI(CallerBFI), CalleeBFI(CalleeBFI),
+ UpdateProfile(UpdateProfile) {}
/// If non-null, InlineFunction will update the callgraph to reflect the
/// changes it makes.
@@ -223,6 +224,10 @@
/// `InlinedCalls` above is used.
SmallVector<CallBase *, 8> InlinedCallSites;
+ /// Update profile for callee as well as cloned version. We need to do this
+ /// for regular inlining, but not for inlining from sample profile loader.
+ bool UpdateProfile;
+
void reset() {
StaticAllocas.clear();
InlinedCalls.clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98187.330011.patch
Type: text/x-patch
Size: 3224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/f9d2ee15/attachment.bin>
More information about the llvm-commits
mailing list