Skip to content

Commit

Permalink
[BOLT] Fix issue with strict and builtin_unreachable
Browse files Browse the repository at this point in the history
Summary:
In strict mode, a jump table with targets generated by
builtin_unreachable (located at the very end of the function) was
asserting when being recreated by postProcessIndirectBranches. Fix
this.

(cherry picked from FBD19614981)
  • Loading branch information
rafaelauler authored and maksfb committed Jan 29, 2020
1 parent d57513e commit 0080d74
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bolt/src/BinaryFunction.cpp
Expand Up @@ -1608,7 +1608,13 @@ bool BinaryFunction::postProcessIndirectBranches(
JTLabels.emplace(Label);
}
for (const auto *Label : JTLabels) {
LastIndirectJumpBB->addSuccessor(getBasicBlockForLabel(Label));
auto *BB = getBasicBlockForLabel(Label);
// Ignore __builtin_unreachable()
if (!BB) {
assert(Label == getFunctionEndLabel() && "if no BB found, must be end");
continue;
}
LastIndirectJumpBB->addSuccessor(BB);
}
}

Expand Down

0 comments on commit 0080d74

Please sign in to comment.