aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/SampleProfWriter.cpp
diff options
context:
space:
mode:
authorWenlei He <aktoon@gmail.com>2021-03-13 13:55:28 -0800
committerWenlei He <aktoon@gmail.com>2021-03-15 12:22:15 -0700
commita5d30421a62cee0217afeac194d111eba9adb15e (patch)
tree846a9cc4bdd10f8462bd59bed258077867648fae /llvm/lib/ProfileData/SampleProfWriter.cpp
parent9cf5220c5c4af0ec1d0abeb2b5c92bb44b6e217d (diff)
downloadllvm-a5d30421a62cee0217afeac194d111eba9adb15e.zip
llvm-a5d30421a62cee0217afeac194d111eba9adb15e.tar.gz
llvm-a5d30421a62cee0217afeac194d111eba9adb15e.tar.bz2
[CSSPGO] Load context profile for external functions in PreLink and populate ThinLTO import list
For ThinLTO's prelink compilation, we need to put external inline candidates into an import list attached to function's entry count metadata. This enables ThinLink to treat such cross module callee as hot in summary index, and later helps postlink to import them for profile guided cross module inlining. For AutoFDO, the import list is retrieved by traversing the nested inlinee functions. For CSSPGO, since profile is flatterned, a few things need to happen for it to work: - When loading input profile in extended binary format, we need to load all child context profile whose parent is in current module, so context trie for current module includes potential cross module inlinee. - In order to make the above happen, we need to know whether input profile is CSSPGO profile before start reading function profile, hence a flag for profile summary section is added. - When searching for cross module inline candidate, we need to walk through the context trie instead of nested inlinee profile (callsite sample of AutoFDO profile). - Now that we have more accurate counts with CSSPGO, we swtiched to use entry count instead of total count to decided if an external callee is potentially beneficial to inline. This make it consistent with how we determine whether call tagert is potential inline candidate. Differential Revision: https://reviews.llvm.org/D98590
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProfWriter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 8939d3a..7a00c3f 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -237,6 +237,8 @@ std::error_code SampleProfileWriterExtBinaryBase::writeOneSection(
setToCompressSection(SecProfileSymbolList);
if (Type == SecFuncMetadata && FunctionSamples::ProfileIsProbeBased)
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsProbeBased);
+ if (Type == SecProfSummary && FunctionSamples::ProfileIsCS)
+ addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFullContext);
uint64_t SectionStart = markSectionStart(Type, LayoutIdx);
switch (Type) {