[llvm-commits] [llvm] r100544 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Gabor Greif ggreif at gmail.com
Tue Apr 6 11:45:08 PDT 2010


Author: ggreif
Date: Tue Apr  6 13:45:08 2010
New Revision: 100544

URL: http://llvm.org/viewvc/llvm-project?rev=100544&view=rev
Log:
use CallSite to access calls vs. invokes uniformly
and remove assumptions about operand order

Modified:
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=100544&r1=100543&r2=100544&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Apr  6 13:45:08 2010
@@ -682,16 +682,17 @@
         Changed = true;
       }
     } else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
-      if (I->getOperand(0) == V) {
+      CallSite CS(I);
+      if (CS.getCalledValue() == V) {
         // Calling through the pointer!  Turn into a direct call, but be careful
         // that the pointer is not also being passed as an argument.
-        I->setOperand(0, NewV);
+        CS.setCalledFunction(NewV);
         Changed = true;
         bool PassedAsArg = false;
-        for (unsigned i = 1, e = I->getNumOperands(); i != e; ++i)
-          if (I->getOperand(i) == V) {
+        for (unsigned i = 0, e = CS.arg_size(); i != e; ++i)
+          if (CS.getArgument(i) == V) {
             PassedAsArg = true;
-            I->setOperand(i, NewV);
+            CS.setArgument(i, NewV);
           }
 
         if (PassedAsArg) {





More information about the llvm-commits mailing list