summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/Mem2Reg.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-06-25 14:58:56 +0000
committerChris Lattner <sabre@nondot.org>2003-06-25 14:58:56 +0000
commit83c39d2edb478e54818b9acc6685c001b76255c6 (patch)
tree20fa4ba9ca73c880119ae0be14fc35f5349c760b /lib/Transforms/Utils/Mem2Reg.cpp
parent4f7ae85eda4aca2eb582fcabcbbbe1c4a7e6fc9f (diff)
downloadllvm-83c39d2edb478e54818b9acc6685c001b76255c6.tar.gz
llvm-83c39d2edb478e54818b9acc6685c001b76255c6.tar.bz2
llvm-83c39d2edb478e54818b9acc6685c001b76255c6.tar.xz
Fix bug: Mem2Reg/2003-06-26-IterativePromote.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6901 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Mem2Reg.cpp')
-rw-r--r--lib/Transforms/Utils/Mem2Reg.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp
index 6bd859a403..b731ab1a4f 100644
--- a/lib/Transforms/Utils/Mem2Reg.cpp
+++ b/lib/Transforms/Utils/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.