summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-08-31 20:55:20 +0000
committerBill Wendling <isanbard@gmail.com>2011-08-31 20:55:20 +0000
commit770d0f070034363e87e3ada43d5ffb4afba91342 (patch)
treedc1c1f8f1bc15d4d3af08fe020b80c98c38b7e12 /llvm/lib/Transforms/Scalar/SCCP.cpp
parenta455a0b1e7eff8cce066e3a0c0782311cab5c073 (diff)
downloadbcm5719-llvm-770d0f070034363e87e3ada43d5ffb4afba91342.tar.gz
bcm5719-llvm-770d0f070034363e87e3ada43d5ffb4afba91342.zip
Make sure we aren't deleting the landingpad instruction.
The landingpad instruction is required in the landing pad block. Because we're not deleting terminating instructions, the invoke may still jump to here (see Transforms/SCCP/2004-11-16-DeadInvoke.ll). Remove all uses of the landingpad instruction, but keep it around until code-gen can remove the basic block. llvm-svn: 138890
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index cfe750c5fa2..3d52afa2e10 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -1681,15 +1681,31 @@ FunctionPass *llvm::createSCCPPass() {
static void DeleteInstructionInBlock(BasicBlock *BB) {
DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
++NumDeadBlocks;
-
+
+ // Check to see if there are non-terminating instructions to delete.
+ if (isa<TerminatorInst>(BB->begin()))
+ return;
+
// Delete the instructions backwards, as it has a reduced likelihood of
// having to update as many def-use and use-def chains.
- while (!isa<TerminatorInst>(BB->begin())) {
- Instruction *I = --BasicBlock::iterator(BB->getTerminator());
-
+ std::vector<Instruction*> WorkList;
+ WorkList.reserve(BB->size());
+ BasicBlock::iterator I = --BasicBlock::iterator(BB->getTerminator());
+
+ while (true) {
if (!I->use_empty())
I->replaceAllUsesWith(UndefValue::get(I->getType()));
- BB->getInstList().erase(I);
+ WorkList.push_back(I);
+ if (I == BB->begin())
+ break;
+ --I;
+ }
+
+ for (std::vector<Instruction*>::iterator
+ II = WorkList.begin(), IE = WorkList.end(); II != IE; ++II) {
+ if (isa<LandingPadInst>(*II))
+ continue;
+ BB->getInstList().erase(*II);
++NumInstRemoved;
}
}
OpenPOWER on IntegriCloud