[PATCH] D110859: [llvm-profgen] Support symbol list for accurate profile
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 30 10:43:05 PDT 2021
wlei created this revision.
wlei added reviewers: hoy, wenlei, wmi.
Herald added a subscriber: lxfind.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Support symbol list in non-CS profile generation along with extended binary format.
https://reviews.llvm.org/D110859
Files:
llvm/test/tools/llvm-profgen/inline-noprobe2.test
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfileGenerator.h
Index: llvm/tools/llvm-profgen/ProfileGenerator.h
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.h
+++ llvm/tools/llvm-profgen/ProfileGenerator.h
@@ -50,8 +50,8 @@
protected:
// Use SampleProfileWriter to serialize profile map
- void write(std::unique_ptr<SampleProfileWriter> Writer,
- SampleProfileMap &ProfileMap);
+ virtual void write(std::unique_ptr<SampleProfileWriter> Writer,
+ SampleProfileMap &ProfileMap);
/*
For each region boundary point, mark if it is begin or end (or both) of
the region. Boundary points are inclusive. Log the sample count as well
@@ -104,6 +104,8 @@
void populateBodySamplesForAllFunctions(const RangeSample &RangeCounter);
void
populateBoundarySamplesForAllFunctions(const BranchSample &BranchCounters);
+ void write(std::unique_ptr<SampleProfileWriter> Writer,
+ SampleProfileMap &ProfileMap) override;
};
using ProbeCounterMap =
Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -94,6 +94,23 @@
exitWithError(std::move(EC));
}
+void ProfileGenerator::write(std::unique_ptr<SampleProfileWriter> Writer,
+ SampleProfileMap &ProfileMap) {
+ // Populate profile symbol list if extended binary format is used, currently
+ // only support for non-CS profile.
+ ProfileSymbolList SymbolList;
+ if (OutputFormat == SPF_Ext_Binary) {
+ for (const auto &Item : ProfileMap) {
+ const FunctionSamples Profile = Item.second;
+ SymbolList.add(Profile.getName(), true);
+ }
+ }
+ Writer->setProfileSymbolList(&SymbolList);
+
+ if (std::error_code EC = Writer->write(ProfileMap))
+ exitWithError(std::move(EC));
+}
+
void ProfileGeneratorBase::write() {
auto WriterOrErr = SampleProfileWriter::create(OutputFilename, OutputFormat);
if (std::error_code EC = WriterOrErr.getError())
Index: llvm/test/tools/llvm-profgen/inline-noprobe2.test
===================================================================
--- llvm/test/tools/llvm-profgen/inline-noprobe2.test
+++ llvm/test/tools/llvm-profgen/inline-noprobe2.test
@@ -2,6 +2,15 @@
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK
+; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t
+; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
+
+; CHECK-SYM-LIST: Dump profile symbol list
+; CHECK-SYM-LIST: main
+; CHECK-SYM-LIST: partition_pivot_first
+; CHECK-SYM-LIST: partition_pivot_last
+; CHECK-SYM-LIST: quick_sort
+
;CHECK: partition_pivot_first:1045:5
;CHECK-NEXT: 0: 5
;CHECK-NEXT: 1: 5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110859.376275.patch
Type: text/x-patch
Size: 3048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210930/47b65f95/attachment.bin>
More information about the llvm-commits
mailing list