1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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
This commit is contained in:
Bill Wendling 2011-08-31 20:55:20 +00:00
parent 4024b91dbe
commit df24e0d185

View File

@ -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;
}
}