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 | d15302afa04f5abaad8fd36217d10de9dd3d7a85 (patch) | |
tree | fc06cb5411859c5e3ec78b653eb6b428caef75d1 /llvm/lib/Transforms/Scalar/SCCP.cpp | |
parent | f87c75706f2a97785d4afd5cbdebeb7e1ae3c08d (diff) | |
download | bcm5719-llvm-d15302afa04f5abaad8fd36217d10de9dd3d7a85.tar.gz bcm5719-llvm-d15302afa04f5abaad8fd36217d10de9dd3d7a85.zip |
Fix IPSCCP's code for deleting dead blocks to tolerate outstanding
blockaddress users. This fixes PR5569.
llvm-svn: 89483
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index c202a2c41de..977827841d9 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/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 |