diff options
author | Dan Gohman <gohman@apple.com> | 2009-11-20 20:19:14 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-11-20 20:19:14 +0000 |
commit | 082f11b74a4bc1ed1434757aa57582a4232e8f29 (patch) | |
tree | 0e57e9eb4d7fb54cd99739a679ee734204321624 /lib/Transforms | |
parent | 9d5e4247ca66b21f37c9417c865bd715e93ba960 (diff) | |
download | external_llvm-082f11b74a4bc1ed1434757aa57582a4232e8f29.zip external_llvm-082f11b74a4bc1ed1434757aa57582a4232e8f29.tar.gz external_llvm-082f11b74a4bc1ed1434757aa57582a4232e8f29.tar.bz2 |
Fix IPSCCP's code for deleting dead blocks to tolerate outstanding
blockaddress users. This fixes PR5569.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89483 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index c202a2c..9778278 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1869,8 +1869,12 @@ bool IPSCCP::runOnModule(Module &M) { for (unsigned i = 0, e = BlocksToErase.size(); i != e; ++i) { // If there are any PHI nodes in this successor, drop entries for BB now. BasicBlock *DeadBB = BlocksToErase[i]; - while (!DeadBB->use_empty()) { - Instruction *I = cast<Instruction>(DeadBB->use_back()); + for (Value::use_iterator UI = DeadBB->use_begin(), UE = DeadBB->use_end(); + UI != UE; ) { + // Ignore blockaddress users; BasicBlock's dtor will handle them. + Instruction *I = dyn_cast<Instruction>(*UI++); + if (!I) continue; + bool Folded = ConstantFoldTerminator(I->getParent()); if (!Folded) { // The constant folder may not have been able to fold the terminator |