diff options
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 2 | ||||
-rw-r--r-- | test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 429b61b6e5..6b8430f028 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -670,6 +670,8 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) { } else if (SwitchInst *SI = dyn_cast<SwitchInst>(Terminator)) { Condition = SI->getCondition(); } else if (IndirectBrInst *IB = dyn_cast<IndirectBrInst>(Terminator)) { + // Can't thread indirect branch with no successors. + if (IB->getNumSuccessors() == 0) return false; Condition = IB->getAddress()->stripPointerCasts(); Preference = WantBlockAddress; } else { diff --git a/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll b/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll new file mode 100644 index 0000000000..1c2c0c75e3 --- /dev/null +++ b/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll @@ -0,0 +1,8 @@ +; RUN: opt < %s -jump-threading +; PR 13405 +; Just check that it doesn't crash / assert + +define i32 @f() nounwind { +entry: + indirectbr i8* undef, [] +} |