summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-11-20 20:19:14 +0000
committerDan Gohman <gohman@apple.com>2009-11-20 20:19:14 +0000
commit6a2392131e2e5b8c4123d69cc959831b4fe719ca (patch)
tree0e57e9eb4d7fb54cd99739a679ee734204321624 /lib/Transforms/Scalar/SCCP.cpp
parentf7751c134a401575f2a2c036456e6377b2de833f (diff)
downloadllvm-6a2392131e2e5b8c4123d69cc959831b4fe719ca.tar.gz
llvm-6a2392131e2e5b8c4123d69cc959831b4fe719ca.tar.bz2
llvm-6a2392131e2e5b8c4123d69cc959831b4fe719ca.tar.xz
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/Scalar/SCCP.cpp')
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index c202a2c41d..977827841d 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