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

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 10 12:05:18 PDT 2002


Changes in directory llvm/lib/Transforms/IPO:

FunctionResolution.cpp updated: 1.10 -> 1.11

---
Log message:


Simplify code (somtimes dramatically), by using the new "auto-insert" feature
of instruction constructors.



---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.10 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.11
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.10	Thu Aug  1 15:01:02 2002
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Tue Sep 10 12:02:57 2002
@@ -60,21 +60,16 @@
   for (unsigned i = 1; i < CI->getNumOperands(); ++i) {
     Value *V = CI->getOperand(i);
 
-    if (V->getType() != ParamTys[i-1]) { // Must insert a cast...
-      Instruction *Cast = new CastInst(V, ParamTys[i-1]);
-      BBI = ++BB->getInstList().insert(BBI, Cast);
-      V = Cast;
-    }
+    if (V->getType() != ParamTys[i-1])  // Must insert a cast...
+      V = new CastInst(V, ParamTys[i-1], "argcast", BBI);
 
     Params.push_back(V);
   }
 
-  Instruction *NewCall = new CallInst(Dest, Params);
-
   // Replace the old call instruction with a new call instruction that calls
   // the real function.
   //
-  BBI = ++BB->getInstList().insert(BBI, NewCall);
+  Instruction *NewCall = new CallInst(Dest, Params, "", BBI);
 
   // Remove the old call instruction from the program...
   BB->getInstList().remove(BBI);
@@ -104,11 +99,10 @@
     // value of the function is actually USED.
     //
     if (!CI->use_empty()) {
+      // Insert the new cast instruction...
       CastInst *NewCast = new CastInst(NewCall, CI->getType(),
-                                       NewCall->getName());
+                                       NewCall->getName(), BBI);
       CI->replaceAllUsesWith(NewCast);
-      // Insert the new cast instruction...
-      BB->getInstList().insert(BBI, NewCast);
     }
   }
 





More information about the llvm-commits mailing list