diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-04 20:01:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-04 20:01:43 +0000 |
commit | 7a5745b38ccdf2794a6f04f01a1c8115ec223ad8 (patch) | |
tree | 0cb30d9e65cb70b654800ce881eef2befdcda0c0 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp | |
parent | 59a28377152789a5144588cc20e9db30759aa46d (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index ad09e68022..c5861832a1 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -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(); } |