summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/TailDuplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 99a7dee..c037ee9 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);
}
}
OpenPOWER on IntegriCloud