[llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Mar 7 20:37:02 PST 2004


Changes in directory llvm/lib/Transforms/IPO:

ArgumentPromotion.cpp updated: 1.2 -> 1.3

---
Log message:

Fix another minor bug, exposed by perlbmk


---
Diffs of the changes:  (+11 -3)

Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.2 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.3
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.2	Sun Mar  7 15:54:50 2004
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp	Sun Mar  7 16:43:27 2004
@@ -136,10 +136,18 @@
   // Second check: make sure that all callers are direct callers.  We can't
   // transform functions that have indirect callers.
   for (Value::use_iterator UI = F->use_begin(), E = F->use_end();
-       UI != E; ++UI)
-    // What about CPRs?
-    if (!CallSite::get(*UI).getInstruction())
+       UI != E; ++UI) {
+    CallSite CS = CallSite::get(*UI);
+    if (Instruction *I = CS.getInstruction()) {
+      // Ensure that this call site is CALLING the function, not passing it as
+      // an argument.
+      for (CallSite::arg_iterator AI = CS.arg_begin(), E = CS.arg_end();
+           AI != E; ++AI)
+        if (*AI == F) return false;   // Passing the function address in!
+    } else {
       return false;  // Cannot promote an indirect call!
+    }
+  }
 
   // Check to see which arguments are promotable.  If an argument is not
   // promotable, remove it from the PointerArgs vector.





More information about the llvm-commits mailing list