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

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 17 18:21:31 PDT 2004



Changes in directory llvm/lib/Transforms/Utils:

PromoteMemoryToRegister.cpp updated: 1.72 -> 1.73
---
Log message:

Fix a bug that occurs when the constant value is the result of an invoke.  In
particular, invoke ret values are only live in the normal dest of the invoke
not in the unwind dest.


---
Diffs of the changes:  (+6 -5)

Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.72 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.73
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.72	Sun Oct 17 16:25:56 2004
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	Sun Oct 17 20:21:17 2004
@@ -95,10 +95,12 @@
 
     void run();
 
-    /// dominates - Return true if BB1 dominates BB2 using the DT.
+    /// dominates - Return true if I1 dominates I2 using the DominatorTree.
     ///
-    bool dominates(BasicBlock *BB1, BasicBlock *BB2) const {
-      return DT[BB1]->dominates(DT[BB2]);
+    bool dominates(Instruction *I1, Instruction *I2) const {
+      if (InvokeInst *II = dyn_cast<InvokeInst>(I1))
+        I1 = II->getNormalDest()->begin();
+      return DT[I1->getParent()]->dominates(DT[I2->getParent()]);
     }
 
   private:
@@ -339,8 +341,7 @@
     for (unsigned i = 0, e = PNs.size(); i != e; ++i)
       if (PNs[i]) {
         if (Value *V = hasConstantValue(PNs[i])) {
-          if (!isa<Instruction>(V) ||
-              dominates(cast<Instruction>(V)->getParent(), I->first)) {
+          if (!isa<Instruction>(V) || dominates(cast<Instruction>(V), PNs[i])) {
             PNs[i]->replaceAllUsesWith(V);
             PNs[i]->eraseFromParent();
             PNs[i] = 0;






More information about the llvm-commits mailing list