[cfe-commits] r100919 - /cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Gabor Greif ggreif at gmail.com
Fri Apr 9 20:45:50 PDT 2010


Author: ggreif
Date: Fri Apr  9 22:45:50 2010
New Revision: 100919

URL: http://llvm.org/viewvc/llvm-project?rev=100919&view=rev
Log:
rely even less on CallInst internals

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=100919&r1=100918&r2=100919&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Apr  9 22:45:50 2010
@@ -1203,11 +1203,11 @@
   llvm::SmallVector<llvm::Value*, 4> ArgList;
 
   for (llvm::Value::use_iterator UI = OldFn->use_begin(), E = OldFn->use_end();
-       UI != E; ) {
+       UI != E; ++UI) {
     // TODO: Do invokes ever occur in C code?  If so, we should handle them too.
-    unsigned OpNo = UI.getOperandNo();
-    llvm::CallInst *CI = dyn_cast<llvm::CallInst>(*UI++);
-    if (!CI || OpNo != 0) continue;
+    llvm::CallInst *CI = dyn_cast<llvm::CallInst>(*UI);
+    llvm::CallSite CS(CI);
+    if (!CI || !CS.isCallee(UI)) continue;
 
     // If the return types don't match exactly, and if the call isn't dead, then
     // we can't transform this call.
@@ -1221,8 +1221,8 @@
     bool DontTransform = false;
     for (llvm::Function::arg_iterator AI = NewFn->arg_begin(),
          E = NewFn->arg_end(); AI != E; ++AI, ++ArgNo) {
-      if (CI->getNumOperands()-1 == ArgNo ||
-          CI->getOperand(ArgNo+1)->getType() != AI->getType()) {
+      if (CS.arg_size() == ArgNo ||
+          CS.getArgument(ArgNo)->getType() != AI->getType()) {
         DontTransform = true;
         break;
       }
@@ -1232,7 +1232,6 @@
 
     // Okay, we can transform this.  Create the new call instruction and copy
     // over the required information.
-    llvm::CallSite CS(CI);
     ArgList.append(CS.arg_begin(), CS.arg_begin() + ArgNo);
     llvm::CallInst *NewCall = llvm::CallInst::Create(NewFn, ArgList.begin(),
                                                      ArgList.end(), "", CI);





More information about the cfe-commits mailing list