[llvm-commits] [llvm] r122758 - /llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Chris Lattner sabre at nondot.org
Mon Jan 3 10:28:15 PST 2011


Author: lattner
Date: Mon Jan  3 12:28:15 2011
New Revision: 122758

URL: http://llvm.org/viewvc/llvm-project?rev=122758&view=rev
Log:
fix PR8895: metadata operands don't have a strong use of their
nested values, so they can change and drop to null, which can
change the hash and cause havok.

It turns out that it isn't a good idea to value number stuff
with metadata operands anyway, so... don't.


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

Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=122758&r1=122757&r2=122758&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Mon Jan  3 12:28:15 2011
@@ -145,9 +145,15 @@
     }
     
     static bool canHandle(Instruction *Inst) {
-      if (CallInst *CI = dyn_cast<CallInst>(Inst))
-        return CI->onlyReadsMemory();
-      return false;
+      CallInst *CI = dyn_cast<CallInst>(Inst);
+      if (CI == 0 || !CI->onlyReadsMemory())
+        return false;
+      
+      // Check that there are no metadata operands.
+      for (unsigned i = 0, e = CI->getNumOperands(); i != e; ++i)
+        if (CI->getOperand(i)->getType()->isMetadataTy())
+          return false;
+      return true;
     }
   };
 }
@@ -407,7 +413,7 @@
         if (LastStore &&
             LastStore->getPointerOperand() == SI->getPointerOperand()) {
           DEBUG(dbgs() << "EarlyCSE DEAD STORE: " << *LastStore << "  due to: "
-                << *Inst << '\n');
+                       << *Inst << '\n');
           LastStore->eraseFromParent();
           Changed = true;
           ++NumDSE;





More information about the llvm-commits mailing list