Skip to content

Commit fd3642a

Browse files
committed
[BOLT] Change scheduling policy to SP_INT_LINEAR
- count the total applicable functions, and only run the passes if it's more than 0. This way we do not get a warning on the scheduling policy change.
1 parent 8e03527 commit fd3642a

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

bolt/lib/Passes/InsertNegateRAStatePass.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,26 @@ Error InsertNegateRAState::runOnFunctions(BinaryContext &BC) {
128128
return !BF.containedNegateRAState() || BF.isIgnored();
129129
};
130130

131-
ParallelUtilities::runOnEachFunction(
132-
BC, ParallelUtilities::SchedulingPolicy::SP_TRIVIAL, WorkFun,
133-
SkipPredicate, "InsertNegateRAStatePass");
134-
135-
BC.outs() << "BOLT-INFO: rewritten pac-ret DWARF info in "
136-
<< FunctionsModified << " out of " << BC.getBinaryFunctions().size()
137-
<< " functions "
138-
<< format("(%.2lf%%).\n", (100.0 * FunctionsModified) /
139-
BC.getBinaryFunctions().size());
131+
int Total = llvm::count_if(
132+
BC.getBinaryFunctions(),
133+
[&](std::pair<const unsigned long, BinaryFunction> &P) {
134+
return P.second.containedNegateRAState() && !P.second.isIgnored();
135+
});
136+
137+
// If we attempt to run the pass, but SkipPredicate skips all functions,
138+
// we get a warning that the SchedulingPolicy is changed to trivial.
139+
// This would break bolt/test/AArch64/unmarked-data.test.
140+
if (Total != 0) {
141+
ParallelUtilities::runOnEachFunction(
142+
BC, ParallelUtilities::SchedulingPolicy::SP_INST_LINEAR, WorkFun,
143+
SkipPredicate, "InsertNegateRAStatePass");
144+
145+
BC.outs() << "BOLT-INFO: rewritten pac-ret DWARF info in "
146+
<< FunctionsModified << " out of "
147+
<< BC.getBinaryFunctions().size() << " functions "
148+
<< format("(%.2lf%%).\n", (100.0 * FunctionsModified) /
149+
BC.getBinaryFunctions().size());
150+
}
140151
return Error::success();
141152
}
142153

bolt/lib/Passes/MarkRAStates.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,24 @@ Error MarkRAStates::runOnFunctions(BinaryContext &BC) {
134134
return !BF.containedNegateRAState() || BF.isIgnored();
135135
};
136136

137-
ParallelUtilities::runOnEachFunction(
138-
BC, ParallelUtilities::SchedulingPolicy::SP_TRIVIAL, WorkFun,
139-
SkipPredicate, "MarkRAStates");
140-
141137
int Total = llvm::count_if(
142138
BC.getBinaryFunctions(),
143139
[&](std::pair<const unsigned long, BinaryFunction> &P) {
144140
return P.second.containedNegateRAState() && !P.second.isIgnored();
145141
});
146-
BC.outs() << "BOLT-INFO: MarkRAStates ran on " << Total
147-
<< " functions. Ignored " << FunctionsIgnored << " functions "
148-
<< format("(%.2lf%%)", (100.0 * FunctionsIgnored) / Total)
149-
<< " because of CFI inconsistencies.\n";
142+
143+
// If we attempt to run the pass, but SkipPredicate skips all functions,
144+
// we get a warning that the SchedulingPolicy is changed to trivial.
145+
// This would break bolt/test/AArch64/unmarked-data.test.
146+
if (Total != 0) {
147+
ParallelUtilities::runOnEachFunction(
148+
BC, ParallelUtilities::SchedulingPolicy::SP_INST_LINEAR, WorkFun,
149+
SkipPredicate, "MarkRAStates");
150+
BC.outs() << "BOLT-INFO: MarkRAStates ran on " << Total
151+
<< " functions. Ignored " << FunctionsIgnored << " functions "
152+
<< format("(%.2lf%%)", (100.0 * FunctionsIgnored) / Total)
153+
<< " because of CFI inconsistencies.\n";
154+
}
150155

151156
return Error::success();
152157
}

0 commit comments

Comments
 (0)