summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-19 22:54:01 +0000
committerChris Lattner <sabre@nondot.org>2002-11-19 22:54:01 +0000
commitc362618f2ae651309a59a75dcddca8809fac2dc4 (patch)
tree9a7c287a5036f3278b84163698994159ec32af55 /llvm/lib/Transforms
parent8bce9886c351806d93abf11c32d9d7c2624f9293 (diff)
downloadbcm5719-llvm-c362618f2ae651309a59a75dcddca8809fac2dc4.tar.gz
bcm5719-llvm-c362618f2ae651309a59a75dcddca8809fac2dc4.zip
Minor changes to cloning interface
llvm-svn: 4770
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/InlineSimple.cpp13
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp19
2 files changed, 14 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index b4542ead3e3..6dbab594e8c 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -90,9 +90,14 @@ bool InlineFunction(CallInst *CI) {
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 @@ bool InlineFunction(CallInst *CI) {
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...
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 442ff03df3d..36b3a7e7014 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -37,25 +37,16 @@ static inline void RemapInstruction(Instruction *I,
// ArgMap values.
//
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
- const std::vector<Value*> &ArgMap,
+ std::map<const Value*, Value*> &ValueMap,
std::vector<ReturnInst*> &Returns,
const char *NameSuffix) {
assert(NameSuffix && "NameSuffix cannot be null!");
- assert(OldFunc->asize() == ArgMap.size() &&
- "Improper number of argument values to map specified!");
- // Keep a mapping between the original function's values and the new
- // duplicated code's values. This includes all of: Function arguments,
- // instruction values, constant pool entries, and basic blocks.
- //
- std::map<const Value *, Value*> ValueMap;
-
- // Add all of the function arguments to the mapping...
- unsigned i = 0;
+#ifndef NDEBUG
for (Function::const_aiterator I = OldFunc->abegin(), E = OldFunc->aend();
- I != E; ++I, ++i)
- ValueMap[I] = ArgMap[i];
-
+ I != E; ++I)
+ assert(ValueMap.count(I) && "No mapping from source argument specified!");
+#endif
// Loop over all of the basic blocks in the function, cloning them as
// appropriate. Note that we save BE this way in order to handle cloning of
OpenPOWER on IntegriCloud