diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 13 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 9 | ||||
-rw-r--r-- | lib/VMCore/Linker.cpp | 9 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 30 |
4 files changed, 28 insertions, 33 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index f43fda9087..e27bd26ba2 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -607,17 +607,8 @@ void AssemblyWriter::printFunction(const Function *F) { // Loop over the arguments, printing them... const FunctionType *FT = F->getFunctionType(); - if (!F->isExternal()) { - for(Function::const_aiterator I = F->abegin(), E = F->aend(); I != E; ++I) - printArgument(I); - } else { - // Loop over the arguments, printing them... - for (FunctionType::ParamTypes::const_iterator I = FT->getParamTypes().begin(), - E = FT->getParamTypes().end(); I != E; ++I) { - if (I != FT->getParamTypes().begin()) Out << ", "; - printType(*I); - } - } + for(Function::const_aiterator I = F->abegin(), E = F->aend(); I != E; ++I) + printArgument(I); // Finish printing arguments... if (FT->isVarArg()) { diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index d7e8bea9dd..d03a72a81a 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -61,7 +61,7 @@ void Argument::setName(const std::string &name, SymbolTable *ST) { "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this); Value::setName(name); - if (P && hasName()) P->getSymbolTable()->insert(this); + if (P && hasName()) P->getSymbolTableSure()->insert(this); } void Argument::setParent(Function *parent) { @@ -86,6 +86,13 @@ Function::Function(const FunctionType *Ty, bool isInternal, ArgumentList.setParent(this); ParentSymTab = SymTab = 0; + // Create the arguments vector, all arguments start out unnamed. + for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) { + assert(Ty->getParamType(i) != Type::VoidTy && + "Cannot have void typed arguments!"); + ArgumentList.push_back(new Argument(Ty->getParamType(i))); + } + // Make sure that we get added to a function LeakDetector::addGarbageObject(this); diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index 6753f51657..8fe9113d82 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -323,14 +323,13 @@ static bool LinkFunctionBody(Function *Dest, const Function *Src, 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... diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index b01b5efc84..da3449b95c 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -193,32 +193,30 @@ void Verifier::verifySymbolTable(SymbolTable *ST) { // visitFunction - Verify that a function is ok. // void Verifier::visitFunction(Function &F) { - if (F.isExternal()) return; - - verifySymbolTable(F.getSymbolTable()); - // Check function arguments... const FunctionType *FT = F.getFunctionType(); unsigned NumArgs = F.getArgumentList().size(); Assert2(!FT->isVarArg(), "Cannot define varargs functions in LLVM!", &F, FT); - Assert2(FT->getParamTypes().size() == NumArgs, + Assert2(FT->getNumParams() == NumArgs, "# formal arguments must match # of arguments for function type!", &F, FT); // Check that the argument values match the function type for this function... - if (FT->getParamTypes().size() == NumArgs) { - unsigned i = 0; - for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i) - Assert2(I->getType() == FT->getParamType(i), - "Argument value does not match function argument type!", - I, FT->getParamType(i)); + unsigned i = 0; + for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i) + Assert2(I->getType() == FT->getParamType(i), + "Argument value does not match function argument type!", + I, FT->getParamType(i)); + + if (!F.isExternal()) { + verifySymbolTable(F.getSymbolTable()); + + // Check the entry node + BasicBlock *Entry = &F.getEntryNode(); + Assert1(pred_begin(Entry) == pred_end(Entry), + "Entry block to function must not have predecessors!", Entry); } - - // Check the entry node - BasicBlock *Entry = &F.getEntryNode(); - Assert1(pred_begin(Entry) == pred_end(Entry), - "Entry block to function must not have predecessors!", Entry); } |