[PATCH] D109088: [CSSPGO] Honor preinliner decision for ThinLTO importing
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 1 13:52:05 PDT 2021
wenlei created this revision.
wenlei added reviewers: hoy, wmi, wlei.
Herald added subscribers: ormris, modimo, lxfind, hiraditya, inglorion.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When pre-inliner decision is used for CSSPGO, we should take that into account for ThinLTO importing as well, so post-link sample loader inliner can favor that decision. This is handled by a small tweak in this patch. It also includes a change to transfer preinliner decision when merging context.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109088
Files:
llvm/lib/Transforms/IPO/SampleContextTracker.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -977,7 +977,14 @@
// For CSSPGO profile, retrieve candidate profile by walking over the
// trie built for context profile. Note that also take call targets
// even if callee doesn't have a corresponding context profile.
- if (!CalleeSample || CalleeSample->getEntrySamples() < Threshold)
+ if (!CalleeSample)
+ continue;
+
+ // If pre-inliner decision is used, honor that for importing as well.
+ bool PreInline =
+ UsePreInlinerDecision &&
+ CalleeSample->getContext().hasAttribute(ContextShouldBeInlined);
+ if (!PreInline && CalleeSample->getEntrySamples() < Threshold)
continue;
StringRef Name = CalleeSample->getFuncName();
Index: llvm/lib/Transforms/IPO/SampleContextTracker.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleContextTracker.cpp
+++ llvm/lib/Transforms/IPO/SampleContextTracker.cpp
@@ -545,6 +545,8 @@
ToSamples->merge(*FromSamples);
ToSamples->getContext().setState(SyntheticContext);
FromSamples->getContext().setState(MergedContext);
+ if (FromSamples->getContext().hasAttribute(ContextShouldBeInlined))
+ ToSamples->getContext().setAttribute(ContextShouldBeInlined);
} else if (FromSamples) {
// Transfer FromSamples from FromNode to ToNode
ToNode.setFunctionSamples(FromSamples);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109088.370049.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210901/4420a00c/attachment.bin>
More information about the llvm-commits
mailing list