[llvm-commits] [llvm] r40817 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Chris Lattner
sabre at nondot.org
Sat Aug 4 13:01:44 PDT 2007
Author: lattner
Date: Sat Aug 4 15:01:43 2007
New Revision: 40817
URL: http://llvm.org/viewvc/llvm-project?rev=40817&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40817&r1=40816&r2=40817&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sat Aug 4 15:01:43 2007
@@ -686,10 +686,10 @@
}
// 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 @@
}
}
}
+
+ // 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();
}
More information about the llvm-commits
mailing list