summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJulien Lerouge <jlerouge@apple.com>2012-10-23 00:23:46 +0000
committerJulien Lerouge <jlerouge@apple.com>2012-10-23 00:23:46 +0000
commitd7fa5e420d933dc2b354ff307e1344e380e45d01 (patch)
treeadffa6421fa088509f51580f6e0532bd67d5932b /llvm/lib
parentbc08ab450ac340dab4cf9fca0659cfc1f4211d48 (diff)
downloadbcm5719-llvm-d7fa5e420d933dc2b354ff307e1344e380e45d01.tar.gz
bcm5719-llvm-d7fa5e420d933dc2b354ff307e1344e380e45d01.zip
Explain why DenseMap is still used here instead of MapVector.
llvm-svn: 166454
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index f6ad3b8b9e8..fb65a1847ca 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -212,7 +212,11 @@ namespace {
///
DenseMap<AllocaInst*, unsigned> AllocaLookup;
- /// NewPhiNodes - The PhiNodes we're adding.
+ /// NewPhiNodes - The PhiNodes we're adding. That map is used to simplify
+ /// some Phi nodes as we iterate over it, so it should have deterministic
+ /// iterators. We could use a MapVector, but since we already maintain a
+ /// map from BasicBlock* to a stable numbering (BBNumbers), the DenseMap is
+ /// more efficient (also supports removal).
///
DenseMap<std::pair<unsigned, unsigned>, PHINode*> NewPhiNodes;
@@ -588,6 +592,10 @@ void PromoteMem2Reg::run() {
while (EliminatedAPHI) {
EliminatedAPHI = false;
+ // Iterating over NewPhiNodes is deterministic, so it is safe to try to
+ // simplify and RUAW them as we go. If it was not, we could add uses to
+ // the values we replace with in a non deterministic order, thus creating
+ // non deterministic def->use chains.
for (DenseMap<std::pair<unsigned, unsigned>, PHINode*>::iterator I =
NewPhiNodes.begin(), E = NewPhiNodes.end(); I != E;) {
PHINode *PN = I->second;
OpenPOWER on IntegriCloud