Skip to content

Commit 551f8c1

Browse files
committed
[llvm-profdata] Enabled functionality to write split-layout profile
Using the flag `-split_layout` in llvm-profdata merge, the output profile can write profiles with and without inlined function into two different extbinary sections (and their FuncOffsetTable too). The section without inlined functions are marked with `SecFlagFlat` and is skipped by ThinLTO because it provides no useful info. The split layout feature was already implemented in SampleProfWriter but previously there is no way from the tool to use it.
1 parent a7ba73b commit 551f8c1

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

llvm/docs/CommandGuide/llvm-profdata.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ OPTIONS
162162
coverage for the optimized target. This option can only be used with
163163
sample-based profile in extbinary format.
164164

165+
.. option:: --split_layout=[true|false]
166+
167+
Split the profile data section to two with one containing sample profiles with
168+
inlined functions and the other not. This option can only be used with
169+
sample-based profile in extbinary format.
170+
165171
.. option:: --convert-sample-profile-layout=[nest|flat]
166172

167173
Convert the merged profile into a profile with a new layout. Supported
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RUN: llvm-profdata merge --sample --extbinary --split_layout %p/Inputs/sample-profile.proftext -o %t-output
2+
RUN: diff %t-output %p/Inputs/split-layout.profdata

llvm/tools/llvm-profdata/llvm-profdata.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ cl::opt<bool> GenPartialProfile(
207207
"gen-partial-profile", cl::init(false), cl::Hidden,
208208
cl::sub(MergeSubcommand),
209209
cl::desc("Generate a partial profile (only meaningful for -extbinary)"));
210+
cl::opt<bool> SplitLayout(
211+
"split_layout", cl::init(false), cl::Hidden,
212+
cl::sub(MergeSubcommand),
213+
cl::desc("Split the profile to two sections with one containing sample "
214+
"profiles with inlined functions and the another not (only "
215+
"meaningful for -extbinary)"));
210216
cl::opt<std::string> SupplInstrWithSample(
211217
"supplement-instr-with-sample", cl::init(""), cl::Hidden,
212218
cl::sub(MergeSubcommand),
@@ -1492,6 +1498,12 @@ static void handleExtBinaryWriter(sampleprof::SampleProfileWriter &Writer,
14921498
else
14931499
Writer.setPartialProfile();
14941500
}
1501+
if (SplitLayout) {
1502+
if (OutputFormat != PF_Ext_Binary)
1503+
warn("-split-layout is ignored. Specify -extbinary to enable it");
1504+
else
1505+
Writer.resetSecLayout(SectionLayout::CtxSplitLayout);
1506+
}
14951507
}
14961508

14971509
static void mergeSampleProfile(const WeightedFileVector &Inputs,

0 commit comments

Comments
 (0)