aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-08-03 19:59:35 +0000
committerOwen Anderson <resistor@mac.com>2007-08-03 19:59:35 +0000
commitab8702787d6bcdeaea31fc6a3d4a7fec3a5e18c4 (patch)
treec10a63e0be08e3faddf31d5e9d496c42517ee538 /lib/Transforms
parent4b55c3b0f17cdf548e45899ba069e454c6342bf1 (diff)
Fix a subtle miscompilation. This allows 197.parser to be compiled correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 1f3ecfa2b1..b0a7cabf8b 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -726,21 +726,23 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig,
bool top_level) {
// If we have already computed this value, return the previously computed val.
- Value *V = Phis[BB];
- if (V && ! top_level) return V;
+ DenseMap<BasicBlock*, Value*>::iterator V = Phis.find(BB);
+ if (V != Phis.end() && !top_level) return V->second;
BasicBlock* singlePred = BB->getSinglePredecessor();
if (singlePred) {
- V = GetValueForBlock(singlePred, orig, Phis);
- Phis[BB] = V;
- return V;
+ Value *ret = GetValueForBlock(singlePred, orig, Phis);
+ Phis[BB] = ret;
+ return ret;
}
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
// now, then get values to fill in the incoming values for the PHI.
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle",
BB->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
- Phis[BB] = PN;
+
+ if (Phis.count(BB) == 0)
+ Phis.insert(std::make_pair(BB, PN));
bool all_same = true;
Value* first = 0;