[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 24 16:20:00 PDT 2002


Changes in directory llvm/lib/Transforms/Scalar:

PromoteMemoryToRegister.cpp updated: 1.30 -> 1.31

---
Log message:

  - Fix bug: Mem2Reg/2002-05-01-ShouldNotPromoteThisAlloca.ll



---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.30 llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.31
--- llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.30	Tue Sep 10 17:38:47 2002
+++ llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp	Tue Sep 24 16:19:41 2002
@@ -79,8 +79,13 @@
   // Only allow direct loads and stores...
   for (Value::use_const_iterator UI = AI->use_begin(), UE = AI->use_end();
        UI != UE; ++UI)     // Loop over all of the uses of the alloca
-    if (!isa<LoadInst>(*UI) && !isa<StoreInst>(*UI))
-      return false;   // Not a load or store?
+    if (!isa<LoadInst>(*UI))
+      if (const StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
+        if (SI->getOperand(0) == AI)
+          return false;   // Don't allow a store of the AI, only INTO the AI.
+      } else {
+        return false;   // Not a load or store?
+      }
   
   return true;
 }





More information about the llvm-commits mailing list