[llvm-commits] [llvm] r40791 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Fri Aug 3 12:59:35 PDT 2007


Author: resistor
Date: Fri Aug  3 14:59:35 2007
New Revision: 40791

URL: http://llvm.org/viewvc/llvm-project?rev=40791&view=rev
Log:
Fix a subtle miscompilation.  This allows 197.parser to be compiled correctly.

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40791&r1=40790&r2=40791&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Aug  3 14:59:35 2007
@@ -726,21 +726,23 @@
                                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;





More information about the llvm-commits mailing list