aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-05 03:39:10 +0000
committerChris Lattner <sabre@nondot.org>2003-10-05 03:39:10 +0000
commit92581c24a3b9c4ec2c31ae1985eb5980c5f5c86f (patch)
tree11a0d531899ebbd5b11704e29a8058813d8d619a /lib/Transforms/Utils
parent036f1e7478ed7b104fe4a5b895377796a20b9222 (diff)
downloadexternal_llvm-92581c24a3b9c4ec2c31ae1985eb5980c5f5c86f.zip
external_llvm-92581c24a3b9c4ec2c31ae1985eb5980c5f5c86f.tar.gz
external_llvm-92581c24a3b9c4ec2c31ae1985eb5980c5f5c86f.tar.bz2
There is no need for separate WriteSets and PhiNodeBlocks lists. It is just a
work-list of value definitions. This allows elimination of the explicit 'iterative' step of the algorithm, and also reuses temporary memory better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8861 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index dae22da..4bfc4e0 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -81,7 +81,6 @@ namespace {
};
} // end of anonymous namespace
-
void PromoteMem2Reg::run() {
Function &F = *DF.getRoot()->getParent();
@@ -97,11 +96,11 @@ void PromoteMem2Reg::run() {
// Calculate the set of write-locations for each alloca. This is analogous
// to counting the number of 'redefinitions' of each variable.
- std::vector<BasicBlock*> WriteSets;
+ std::vector<BasicBlock*> DefiningBlocks;
for (Value::use_iterator U =AI->use_begin(), E = AI->use_end(); U != E; ++U)
if (StoreInst *SI = dyn_cast<StoreInst>(cast<Instruction>(*U)))
// jot down the basic-block it came from
- WriteSets.push_back(SI->getParent());
+ DefiningBlocks.push_back(SI->getParent());
AllocaLookup[Allocas[i]] = i;
@@ -112,27 +111,18 @@ void PromoteMem2Reg::run() {
// Compute the locations where PhiNodes need to be inserted. Look at the
// dominance frontier of EACH basic-block we have a write in.
//
- for (unsigned j = 0; j != WriteSets.size(); j++) {
+ while (!DefiningBlocks.empty()) {
+ BasicBlock *BB = DefiningBlocks.back();
+ DefiningBlocks.pop_back();
+
// Look up the DF for this write, add it to PhiNodes
- DominanceFrontier::const_iterator it = DF.find(WriteSets[j]);
+ DominanceFrontier::const_iterator it = DF.find(BB);
if (it != DF.end()) {
const DominanceFrontier::DomSetType &S = it->second;
for (DominanceFrontier::DomSetType::iterator P = S.begin(),PE = S.end();
P != PE; ++P)
if (QueuePhiNode(*P, i))
- PhiNodeBlocks.push_back(*P);
- }
- }
-
- // Perform iterative step
- for (unsigned k = 0; k != PhiNodeBlocks.size(); k++) {
- DominanceFrontier::const_iterator it = DF.find(PhiNodeBlocks[k]);
- if (it != DF.end()) {
- const DominanceFrontier::DomSetType &S = it->second;
- for (DominanceFrontier::DomSetType::iterator
- P = S.begin(), PE = S.end(); P != PE; ++P)
- if (QueuePhiNode(*P, i))
- PhiNodeBlocks.push_back(*P);
+ DefiningBlocks.push_back(*P);
}
}
}