aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-02 00:17:47 +0000
committerDan Gohman <gohman@apple.com>2009-07-02 00:17:47 +0000
commitf530c92cd55f35f64904e42e38b3a2bc92b347cb (patch)
tree90599072a77b48b5306f061b7006dcff85bf21d7 /lib/Transforms
parentc70e62110b7e165ab8f04c38ffd97f905dcda95d (diff)
Fix a bunch of other places that used operator[] to test whether
a key is present in a std::map or DenseMap to use find instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp16
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp14
2 files changed, 19 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 5a70fc3bc6..c3aee01e64 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -935,9 +935,11 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// Remap operands to patch up intra-block references.
for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i)
- if (Instruction *Inst = dyn_cast<Instruction>(New->getOperand(i)))
- if (Value *Remapped = ValueMapping[Inst])
- New->setOperand(i, Remapped);
+ if (Instruction *Inst = dyn_cast<Instruction>(New->getOperand(i))) {
+ DenseMap<Instruction*, Value*>::iterator I = ValueMapping.find(Inst);
+ if (I != ValueMapping.end())
+ New->setOperand(i, I->second);
+ }
}
// We didn't copy the terminator from BB over to NewBB, because there is now
@@ -953,9 +955,11 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
Value *IV = PN->getIncomingValueForBlock(BB);
// Remap the value if necessary.
- if (Instruction *Inst = dyn_cast<Instruction>(IV))
- if (Value *MappedIV = ValueMapping[Inst])
- IV = MappedIV;
+ if (Instruction *Inst = dyn_cast<Instruction>(IV)) {
+ DenseMap<Instruction*, Value*>::iterator I = ValueMapping.find(Inst);
+ if (I != ValueMapping.end())
+ IV = I->second;
+ }
PN->addIncoming(IV, NewBB);
}
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 99a7dee398..c037ee9603 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -317,9 +317,12 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
//
BI = Branch; ++BI; // Get an iterator to the first new instruction
for (; BI != SourceBlock->end(); ++BI)
- for (unsigned i = 0, e = BI->getNumOperands(); i != e; ++i)
- if (Value *Remapped = ValueMapping[BI->getOperand(i)])
- BI->setOperand(i, Remapped);
+ for (unsigned i = 0, e = BI->getNumOperands(); i != e; ++i) {
+ std::map<Value*, Value*>::const_iterator I =
+ ValueMapping.find(BI->getOperand(i));
+ if (I != ValueMapping.end())
+ BI->setOperand(i, I->second);
+ }
// Next we check to see if any of the successors of DestBlock had PHI nodes.
// If so, we need to add entries to the PHI nodes for SourceBlock now.
@@ -333,8 +336,9 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
Value *IV = PN->getIncomingValueForBlock(DestBlock);
// Remap the value if necessary...
- if (Value *MappedIV = ValueMapping[IV])
- IV = MappedIV;
+ std::map<Value*, Value*>::const_iterator I = ValueMapping.find(IV);
+ if (I != ValueMapping.end())
+ IV = I->second;
PN->addIncoming(IV, SourceBlock);
}
}