- Change Function's so that their argument list is populated when they are
constructed. Before, external functions would have an empty argument list,
now a Function ALWAYS has a populated argument list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4149 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index 7f62f2b..483fba5 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -317,10 +317,10 @@
Function *NewMeth = cast<Function>(GMI->second);
// Okay, first order of business, create the arguments...
- for (Function::aiterator I = m->abegin(), E = m->aend(); I != E; ++I) {
- Argument *NFA = new Argument(ConvertType(I->getType()), I->getName());
- NewMeth->getArgumentList().push_back(NFA);
- LocalValueMap[I] = NFA; // Keep track of value mapping
+ for (Function::aiterator I = m->abegin(), E = m->aend(),
+ DI = NewMeth->abegin(); I != E; ++I, ++DI) {
+ DI->setName(I->getName());
+ LocalValueMap[I] = DI; // Keep track of value mapping
}
diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp
index 6753f51..8fe9113 100644
--- a/lib/Transforms/Utils/Linker.cpp
+++ b/lib/Transforms/Utils/Linker.cpp
@@ -323,14 +323,13 @@
map<const Value*, Value*> LocalMap; // Map for function local values
// Go through and convert function arguments over...
+ Function::aiterator DI = Dest->abegin();
for (Function::const_aiterator I = Src->abegin(), E = Src->aend();
- I != E; ++I) {
- // Create the new function argument and add to the dest function...
- Argument *DFA = new Argument(I->getType(), I->getName());
- Dest->getArgumentList().push_back(DFA);
+ I != E; ++I, ++DI) {
+ DI->setName(I->getName()); // Copy the name information over...
// Add a mapping to our local map
- LocalMap.insert(std::make_pair(I, DFA));
+ LocalMap.insert(std::make_pair(I, DI));
}
// Loop over all of the basic blocks, copying the instructions over...