Skip to content

Commit

Permalink
[BOLT] Disable last basic block assertion.
Browse files Browse the repository at this point in the history
Summary:
While converting code from __builtin_unreachable() we were asserting
that a basic block with a conditional jump and a single CFG successor
was the last one before converting the jump to an unconditional one.

However, if that code was executed after a conditional tail call
conversion in the same function, the original last basic block
will no longer be the last one in the post-conversion layout.

I'm disabling the assertion since it doesn't seem worth it to add
extra checks for the basic block that used to be the last one.

(cherry picked from FBD5570298)
  • Loading branch information
maksfb committed Aug 5, 2017
1 parent ae409f0 commit e4290d0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bolt/BinaryFunction.cpp
Expand Up @@ -1148,12 +1148,13 @@ void BinaryFunction::disassemble(ArrayRef<uint8_t> FunctionData) {
// Assign proper opcode for tail calls, so that they could be
// treated as calls.
if (!IsCall) {
if (!MIA->convertJmpToTailCall(Instruction) &&
opts::Verbosity >= 2) {
if (!MIA->convertJmpToTailCall(Instruction)) {
assert(IsCondBranch && "unknown tail call instruction");
errs() << "BOLT-WARNING: conditional tail call detected in "
<< "function " << *this << " at 0x"
<< Twine::utohexstr(AbsoluteInstrAddr) << ".\n";
if (opts::Verbosity >= 2) {
errs() << "BOLT-WARNING: conditional tail call detected in "
<< "function " << *this << " at 0x"
<< Twine::utohexstr(AbsoluteInstrAddr) << ".\n";
}
}
// TODO: A better way to do this would be using annotations for
// MCInst objects.
Expand Down Expand Up @@ -3141,7 +3142,6 @@ void BinaryFunction::postProcessBranches() {
// falls-through into the next function - hence the block will have only
// one valid successor. Such behaviour is undefined and thus we remove
// the conditional branch while leaving a valid successor.
assert(BB == BasicBlocksLayout.back() && "last basic block expected");
BB->eraseInstruction(std::next(LastInstrRI.base()));
DEBUG(dbgs() << "BOLT-DEBUG: erasing conditional branch in "
<< BB->getName() << " in function " << *this << '\n');
Expand Down

0 comments on commit e4290d0

Please sign in to comment.