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

Chris Lattner lattner at cs.uiuc.edu
Tue Nov 19 16:55:04 PST 2002


Changes in directory llvm/lib/Transforms/IPO:

FunctionInlining.cpp updated: 1.39 -> 1.40

---
Log message:

Minor changes to cloning interface



---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/FunctionInlining.cpp
diff -u llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.39 llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.40
--- llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.39	Tue Nov 19 15:54:05 2002
+++ llvm/lib/Transforms/IPO/FunctionInlining.cpp	Tue Nov 19 16:53:59 2002
@@ -90,9 +90,14 @@
   Function::iterator LastBlock = &OrigBB->getParent()->back();
 
   // Calculate the vector of arguments to pass into the function cloner...
-  std::vector<Value*> ArgVector;
-  for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-    ArgVector.push_back(CI->getOperand(i));
+  std::map<const Value*, Value*> ValueMap;
+  assert((unsigned)std::distance(CalledFunc->abegin(), CalledFunc->aend()) == 
+         CI->getNumOperands()-1 && "No varargs calls can be inlined yet!");
+
+  unsigned i = 1;
+  for (Function::const_aiterator I = CalledFunc->abegin(), E=CalledFunc->aend();
+       I != E; ++I, ++i)
+    ValueMap[I] = CI->getOperand(i);
 
   // Since we are now done with the CallInst, we can delete it.
   delete CI;
@@ -101,7 +106,7 @@
   std::vector<ReturnInst*> Returns;
 
   // Do all of the hard part of cloning the callee into the caller...
-  CloneFunctionInto(OrigBB->getParent(), CalledFunc, ArgVector, Returns, ".i");
+  CloneFunctionInto(OrigBB->getParent(), CalledFunc, ValueMap, Returns, ".i");
 
   // Loop over all of the return instructions, turning them into unconditional
   // branches to the merge point now...





More information about the llvm-commits mailing list