aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorRichard Osborne <richard@xmos.com>2012-07-20 10:36:17 +0000
committerRichard Osborne <richard@xmos.com>2012-07-20 10:36:17 +0000
commitdd2fb6c10b30e70ab8f910e21e583be3e90bb88c (patch)
tree1e7e77fc74349ad773b03517f4db64b33831cb53 /lib/Transforms
parentf7b08226eb44458f6f38cbeaca527028803c725a (diff)
downloadexternal_llvm-dd2fb6c10b30e70ab8f910e21e583be3e90bb88c.zip
external_llvm-dd2fb6c10b30e70ab8f910e21e583be3e90bb88c.tar.gz
external_llvm-dd2fb6c10b30e70ab8f910e21e583be3e90bb88c.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 429b61b..6b8430f 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 {