diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-25 14:58:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-25 14:58:56 +0000 |
commit | b396afde26de93ed002a6cae3773c1f17a607e20 (patch) | |
tree | e205f95fecaf10bcd9ad43f59ce2a3553c5f486c /llvm/lib | |
parent | fec65d7526051bde5d1588900e01849f2ea10d70 (diff) | |
download | bcm5719-llvm-b396afde26de93ed002a6cae3773c1f17a607e20.tar.gz bcm5719-llvm-b396afde26de93ed002a6cae3773c1f17a607e20.zip |
Fix bug: Mem2Reg/2003-06-26-IterativePromote.ll
llvm-svn: 6901
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Mem2Reg.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/Mem2Reg.cpp b/llvm/lib/Transforms/Scalar/Mem2Reg.cpp index 6bd859a4037..b731ab1a4f7 100644 --- a/llvm/lib/Transforms/Scalar/Mem2Reg.cpp +++ b/llvm/lib/Transforms/Scalar/Mem2Reg.cpp @@ -40,19 +40,26 @@ bool PromotePass::runOnFunction(Function &F) { BasicBlock &BB = F.getEntryNode(); // Get the entry node for the function - // Find allocas that are safe to promote, by looking at all instructions in - // the entry node - for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) - if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) // Is it an alloca? - if (isAllocaPromotable(AI, TD)) - Allocas.push_back(AI); - - if (!Allocas.empty()) { + bool Changed = false; + + while (1) { + Allocas.clear(); + + // Find allocas that are safe to promote, by looking at all instructions in + // the entry node + for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) + if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) // Is it an alloca? + if (isAllocaPromotable(AI, TD)) + Allocas.push_back(AI); + + if (Allocas.empty()) break; + PromoteMemToReg(Allocas, getAnalysis<DominanceFrontier>(), TD); NumPromoted += Allocas.size(); - return true; + Changed = true; } - return false; + + return Changed; } // createPromoteMemoryToRegister - Provide an entry point to create this pass. |