diff options
| author | Richard Osborne <richard@xmos.com> | 2012-07-20 10:36:17 +0000 |
|---|---|---|
| committer | Richard Osborne <richard@xmos.com> | 2012-07-20 10:36:17 +0000 |
| commit | 0ab2b0df820664af2c05e70cdb25d53471106145 (patch) | |
| tree | f71bc4c2f3e6ee2f991b394b45a51031c31f9966 /llvm/lib | |
| parent | f02c6069acbf63d8d5234f647e405e11e822a9ad (diff) | |
| download | bcm5719-llvm-0ab2b0df820664af2c05e70cdb25d53471106145.tar.gz bcm5719-llvm-0ab2b0df820664af2c05e70cdb25d53471106145.zip | |
Fix assertion in jump threading (PR13405).
GetBestDestForJumpOnUndef() assumes there is at least 1 successor, which isn't
true if the block ends in an indirect branch with no successors. Fix this by
bailing out earlier in this case.
llvm-svn: 160546
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 429b61b6e50..6b8430f0283 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/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 { |

