[llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Sep 8 13:15:02 PDT 2003


Changes in directory llvm/lib/Analysis:

LoadValueNumbering.cpp updated: 1.5 -> 1.6

---
Log message:

Fix bug: RLE-Preserve-Volatile.ll
Volatile loads and stores must not be value numbered


---
Diffs of the changes:

Index: llvm/lib/Analysis/LoadValueNumbering.cpp
diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.5 llvm/lib/Analysis/LoadValueNumbering.cpp:1.6
--- llvm/lib/Analysis/LoadValueNumbering.cpp:1.5	Mon Aug 18 09:29:03 2003
+++ llvm/lib/Analysis/LoadValueNumbering.cpp	Mon Sep  8 13:13:58 2003
@@ -90,6 +90,10 @@
     getAnalysis<AliasAnalysis>().getMustAliases(V, RetVals);
 
   if (LoadInst *LI = dyn_cast<LoadInst>(V)) {
+    // Volatile loads cannot be replaced with the value of other loads.
+    if (LI->isVolatile())
+      return getAnalysis<ValueNumbering>().getEqualNumberNodes(V, RetVals);
+
     // If we have a load instruction, find all of the load and store
     // instructions that use the same source operand.  We implement this
     // recursively, because there could be a load of a load of a load that are
@@ -119,10 +123,10 @@
            UI != UE; ++UI)
         if (LoadInst *Cand = dyn_cast<LoadInst>(*UI)) {// Is a load of source?
           if (Cand->getParent()->getParent() == F &&   // In the same function?
-              Cand != LI)                              // Not LI itself?
+              Cand != LI && !Cand->isVolatile())       // Not LI itself?
             CandidateLoads.push_back(Cand);     // Got one...
         } else if (StoreInst *Cand = dyn_cast<StoreInst>(*UI)) {
-          if (Cand->getParent()->getParent() == F &&
+          if (Cand->getParent()->getParent() == F && !Cand->isVolatile() &&
               Cand->getOperand(1) == Source)  // It's a store THROUGH the ptr...
             CandidateStores.push_back(Cand);
         }





More information about the llvm-commits mailing list