forked from OSchip/llvm-project
When PromoteLocallyUsedAllocas promoted allocas, it didn't remember
to increment NumLocalPromoted, and didn't actually delete the dead alloca, leading to an extra iteration of mem2reg. llvm-svn: 40817
This commit is contained in:
parent
63c039780c
commit
4a930f9444
|
@ -686,10 +686,10 @@ bool PromoteMem2Reg::PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI) {
|
|||
}
|
||||
|
||||
// After traversing the basic block, there should be no more uses of the
|
||||
// alloca, remove it now.
|
||||
// alloca: remove it now.
|
||||
assert(AI->use_empty() && "Uses of alloca from more than one BB??");
|
||||
if (AST) AST->deleteValue(AI);
|
||||
AI->getParent()->getInstList().erase(AI);
|
||||
AI->eraseFromParent();
|
||||
|
||||
++NumLocalPromoted;
|
||||
return false;
|
||||
|
@ -739,6 +739,17 @@ PromoteLocallyUsedAllocas(BasicBlock *BB, const std::vector<AllocaInst*> &AIs) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// At the end of the block scan, all allocas in CurValues are dead.
|
||||
for (DenseMap<AllocaInst*, Value*>::iterator I = CurValues.begin(),
|
||||
E = CurValues.end(); I != E; ++I) {
|
||||
AllocaInst *AI = I->first;
|
||||
assert(AI->use_empty() && "Uses of alloca from more than one BB??");
|
||||
if (AST) AST->deleteValue(AI);
|
||||
AI->eraseFromParent();
|
||||
}
|
||||
|
||||
NumLocalPromoted += CurValues.size();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue