aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/SampleProfWriter.cpp
diff options
context:
space:
mode:
authorWenlei He <wenlei@fb.com>2021-02-19 22:46:30 -0800
committerWenlei He <aktoon@gmail.com>2021-03-18 22:00:56 -0700
commit1410db70b98d26e9a354373f02d4e4c407468933 (patch)
tree80686bf3687be95952ae080033d1d81fb66f391c /llvm/lib/ProfileData/SampleProfWriter.cpp
parentfff1363ba0ae50da3f8f7b732c90e47e504f18a9 (diff)
downloadllvm-1410db70b98d26e9a354373f02d4e4c407468933.zip
llvm-1410db70b98d26e9a354373f02d4e4c407468933.tar.gz
llvm-1410db70b98d26e9a354373f02d4e4c407468933.tar.bz2
[CSSPGO] Add attribute metadata for context profile
This changes adds attribute field for metadata of context profile. Currently we have an inline attribute that indicates whether the leaf frame corresponding to a context profile was inlined in previous build. This will be used to help estimating inlining and be taken into account when trimming context. Changes for that in llvm-profgen will follow. It will also help tuning. Differential Revision: https://reviews.llvm.org/D98823
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProfWriter.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 7a00c3f..b964348 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -170,12 +170,15 @@ std::error_code SampleProfileWriterExtBinaryBase::writeFuncOffsetTable() {
std::error_code SampleProfileWriterExtBinaryBase::writeFuncMetadata(
const StringMap<FunctionSamples> &Profiles) {
- if (!FunctionSamples::ProfileIsProbeBased)
+ if (!FunctionSamples::ProfileIsProbeBased && !FunctionSamples::ProfileIsCS)
return sampleprof_error::success;
auto &OS = *OutputStream;
for (const auto &Entry : Profiles) {
writeNameIdx(Entry.first());
- encodeULEB128(Entry.second.getFunctionHash(), OS);
+ if (FunctionSamples::ProfileIsProbeBased)
+ encodeULEB128(Entry.second.getFunctionHash(), OS);
+ if (FunctionSamples::ProfileIsCS)
+ encodeULEB128(Entry.second.getContext().getAllAttributes(), OS);
}
return sampleprof_error::success;
}
@@ -239,6 +242,8 @@ std::error_code SampleProfileWriterExtBinaryBase::writeOneSection(
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsProbeBased);
if (Type == SecProfSummary && FunctionSamples::ProfileIsCS)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFullContext);
+ if (Type == SecFuncMetadata && FunctionSamples::ProfileIsCS)
+ addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagHasAttribute);
uint64_t SectionStart = markSectionStart(Type, LayoutIdx);
switch (Type) {
@@ -417,6 +422,10 @@ std::error_code SampleProfileWriterText::writeSample(const FunctionSamples &S) {
OS.indent(Indent + 1);
OS << "!CFGChecksum: " << S.getFunctionHash() << "\n";
}
+ if (FunctionSamples::ProfileIsCS) {
+ OS.indent(Indent + 1);
+ OS << "!Attributes: " << S.getContext().getAllAttributes() << "\n";
+ }
}
return sampleprof_error::success;