Skip to content

Commit 34b6b9b

Browse files
Flag-gate the new pass and resolve review feedback
1 parent 5d207e9 commit 34b6b9b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

llvm/lib/CodeGen/StaticDataSplitter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ bool StaticDataSplitter::splitJumpTablesWithProfiles(
8383
MachineFunction &MF, MachineJumpTableInfo &MJTI) {
8484
int NumChangedJumpTables = 0;
8585
// Regard a jump table as hot by default. If the source and all of destination
86-
// blocks are cold, regard the jump table as cold.
86+
// blocks are cold, regard the jump table as cold. While a destination block
87+
// does not read a jump table (unless it's also a source block), a hot
88+
// destination heuristically makes its jump table hot to accommodate for
89+
// potential profile data skews (from sampled profiles, for example).
8790
DataHotness Hotness = DataHotness::Hot;
8891
for (const auto &MBB : MF) {
8992
// IMPORTANT, `getJumpTableIndex` is a thin wrapper around per-target
@@ -121,11 +124,9 @@ bool StaticDataSplitter::splitJumpTables(MachineFunction &MF) {
121124
if (!MJTI || MJTI->getJumpTables().empty())
122125
return false;
123126

124-
// Place jump tables according to block hotness if block counters are
125-
// available. Check function entry count because BFI depends on it to derive
126-
// block counters.
127+
// Place jump tables according to block hotness if function has profile data.
127128
if (PSI && PSI->hasProfileSummary() && MBFI &&
128-
MF.getFunction().getEntryCount())
129+
MF.getFunction().hasProfileData())
129130
return splitJumpTablesWithProfiles(MF, *MJTI);
130131

131132
// Conservatively place all jump tables in the hot-suffixed section if profile

llvm/lib/CodeGen/TargetPassConfig.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ static cl::opt<bool>
263263
GCEmptyBlocks("gc-empty-basic-blocks", cl::init(false), cl::Hidden,
264264
cl::desc("Enable garbage-collecting empty basic blocks"));
265265

266+
static cl::opt<bool>
267+
SplitStaticData("split-static-data", cl::Hidden, cl::init(false),
268+
cl::desc("Split static data sections into hot and cold "
269+
"section ones using profile information"));
270+
266271
/// Allow standard passes to be disabled by command line options. This supports
267272
/// simple binary flags that either suppress the pass or do nothing.
268273
/// i.e. -disable-mypass=false has no effect.
@@ -1256,8 +1261,9 @@ void TargetPassConfig::addMachinePasses() {
12561261
"performance.\n";
12571262
}
12581263
}
1259-
addPass(createStaticDataSplitterPass());
12601264
addPass(createMachineFunctionSplitterPass());
1265+
if (SplitStaticData)
1266+
addPass(createStaticDataSplitterPass());
12611267
}
12621268
// We run the BasicBlockSections pass if either we need BB sections or BB
12631269
// address map (or both).

0 commit comments

Comments
 (0)