[llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Oct 4 22:40:01 PDT 2003
Changes in directory llvm/lib/Transforms/Utils:
PromoteMemoryToRegister.cpp updated: 1.46 -> 1.47
---
Log message:
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.
---
Diffs of the changes:
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.46 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.47
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.46 Sat Oct 4 22:26:25 2003
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sat Oct 4 22:39:10 2003
@@ -81,7 +81,6 @@
};
} // end of anonymous namespace
-
void PromoteMem2Reg::run() {
Function &F = *DF.getRoot()->getParent();
@@ -97,11 +96,11 @@
// 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 @@
// 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);
}
}
}
More information about the llvm-commits
mailing list