Skip to content

Commit 42df25c

Browse files
committed
[MachineBB] Make sure there are successors in terminatorIsComputedGoto.
Currently terminatorIsComputedGoto will return for blocks with a indirect branch terminator and no successor. If there are no successor, the terminator is likely not a computed goto, return false in that case. Note that this is currently NFC, as the only use checks it only if there are successors, but it will be needed in llvm#150911.
1 parent 8dd9199 commit 42df25c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class MachineBasicBlock
326326
/// Returns true if the original IR terminator is an `indirectbr`. This
327327
/// typically corresponds to a `goto` in C, rather than jump tables.
328328
bool terminatorIsComputedGoto() const {
329-
return back().isIndirectBranch() &&
329+
return back().isIndirectBranch() && !succ_empty() &&
330330
llvm::all_of(successors(), [](const MachineBasicBlock *Succ) {
331331
return Succ->isIRBlockAddressTaken();
332332
});

0 commit comments

Comments
 (0)