Skip to content

Commit b9102ab

Browse files
committed
[BOLT] Review changes
- remove unused PrevInst - add a static PassFailed, and createFatalBOLTError() if the pass failed on any of the threads executed in parallel. This is the same way ADRRelaxationPass handles errors in threads.
1 parent 75cb9f6 commit b9102ab

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bolt/lib/Passes/InsertNegateRAStatePass.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ using namespace llvm;
2121
namespace llvm {
2222
namespace bolt {
2323

24+
static bool PassFailed = false;
25+
2426
void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
27+
if (PassFailed)
28+
return;
29+
2530
BinaryContext &BC = BF.getBinaryContext();
2631

2732
if (BF.getState() == BinaryFunction::State::Empty)
@@ -39,7 +44,6 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
3944
for (FunctionFragment &FF : BF.getLayout().fragments()) {
4045
coverFunctionFragmentStart(BF, FF);
4146
bool FirstIter = true;
42-
MCInst PrevInst;
4347
bool PrevRAState = false;
4448
// As this pass runs after function splitting, we should only check
4549
// consecutive instructions inside FunctionFragments.
@@ -52,6 +56,8 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
5256
if (!RAState) {
5357
BC.errs() << "BOLT-ERROR: unknown RAState after inferUnknownStates "
5458
<< " in function " << BF.getPrintName() << "\n";
59+
PassFailed = true;
60+
return;
5561
}
5662
if (!FirstIter) {
5763
// Consecutive instructions with different RAState means we need to
@@ -62,7 +68,6 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
6268
} else {
6369
FirstIter = false;
6470
}
65-
PrevInst = *It;
6671
PrevRAState = *RAState;
6772
}
6873
}
@@ -90,6 +95,7 @@ void InsertNegateRAState::coverFunctionFragmentStart(BinaryFunction &BF,
9095
if (!RAState) {
9196
BC.errs() << "BOLT-ERROR: unknown RAState after inferUnknownStates "
9297
<< " in function " << BF.getPrintName() << "\n";
98+
PassFailed = true;
9399
return;
94100
}
95101
if (*RAState)
@@ -151,6 +157,8 @@ Error InsertNegateRAState::runOnFunctions(BinaryContext &BC) {
151157
<< " functions "
152158
<< format("(%.2lf%%).\n", (100.0 * FunctionsModified) /
153159
BC.getBinaryFunctions().size());
160+
if (PassFailed)
161+
return createFatalBOLTError("");
154162
return Error::success();
155163
}
156164

0 commit comments

Comments
 (0)