diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-02-05 21:19:13 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-02-05 21:19:13 +0000 |
commit | 688b0490e22eb67623f5aaa24406209be74efcb2 (patch) | |
tree | 69eb17e5f7e3136a7b336ed6c5d0a2ed5692a44d | |
parent | cdedc3b336ff7552e439723fdb96dda68b1dbbdb (diff) |
For PR411:
Adjust to changes in Module interface:
getMainFunction() -> getFunction("main")
getNamedFunction(X) -> getFunction(X)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33922 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 2 | ||||
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/ExtractFunction.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/IndMemRemoval.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/Internalize.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/LowerSetJmp.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/StripSymbols.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/BlockProfiling.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/EdgeProfiling.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/TraceBasicBlocks.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LowerGC.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 4 | ||||
-rw-r--r-- | tools/bugpoint/CrashDebugger.cpp | 2 | ||||
-rw-r--r-- | tools/bugpoint/Miscompilation.cpp | 4 | ||||
-rw-r--r-- | tools/lli/lli.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-upgrade/UpgradeParser.cpp.cvs | 12 | ||||
-rw-r--r-- | tools/llvm-upgrade/UpgradeParser.y | 12 | ||||
-rw-r--r-- | tools/llvm-upgrade/UpgradeParser.y.cvs | 12 | ||||
-rw-r--r-- | tools/llvm2cpp/CppWriter.cpp | 4 |
19 files changed, 46 insertions, 46 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 6791f5776b..0fd6d461e1 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -54,7 +54,7 @@ ExecutionEngine::~ExecutionEngine() { /// general code. Function *ExecutionEngine::FindFunctionNamed(const char *FnName) { for (unsigned i = 0, e = Modules.size(); i != e; ++i) { - if (Function *F = Modules[i]->getModule()->getNamedFunction(FnName)) + if (Function *F = Modules[i]->getModule()->getFunction(FnName)) return F; } return 0; diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index d00e1f2467..8186e7b4d1 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -43,7 +43,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { // If the program doesn't define a main, try pulling one in from a .a file. // This is needed for programs where the main function is defined in an // archive, such f2c'd programs. - Function *Main = M->getMainFunction(); + Function *Main = M->getFunction("main"); if (Main == 0 || Main->isDeclaration()) UndefinedSymbols.insert("main"); diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index 0595b5c2f7..f8771845a6 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -33,7 +33,7 @@ namespace { bool runOnModule(Module &M) { if (Named == 0) { - Named = M.getMainFunction(); + Named = M.getFunction("main"); if (Named == 0) return false; // No function to extract } diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index 0d2f350e85..343fadb637 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -44,7 +44,7 @@ bool IndMemRemPass::runOnModule(Module &M) { //functions, ensuring that all malloc and free that might happen //happen through intrinsics. bool changed = false; - if (Function* F = M.getNamedFunction("free")) { + if (Function* F = M.getFunction("free")) { assert(F->isDeclaration() && "free not external?"); if (!F->use_empty()) { Function* FN = new Function(F->getFunctionType(), @@ -59,7 +59,7 @@ bool IndMemRemPass::runOnModule(Module &M) { changed = true; } } - if (Function* F = M.getNamedFunction("malloc")) { + if (Function* F = M.getFunction("malloc")) { assert(F->isDeclaration() && "malloc not external?"); if (!F->use_empty()) { Function* FN = new Function(F->getFunctionType(), diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 54312b70b1..eebc70a47f 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -95,7 +95,7 @@ bool InternalizePass::runOnModule(Module &M) { // internalize the module, it must be a library or something. // if (ExternalNames.empty()) { - Function *MainFunc = M.getMainFunction(); + Function *MainFunc = M.getFunction("main"); if (MainFunc == 0 || MainFunc->isDeclaration()) return false; // No main found, must be a library... diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index a7da282c6a..8941c8b7b7 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -127,8 +127,8 @@ bool LowerSetJmp::runOnModule(Module& M) { bool Changed = false; // These are what the functions are called. - Function* SetJmp = M.getNamedFunction("llvm.setjmp"); - Function* LongJmp = M.getNamedFunction("llvm.longjmp"); + Function* SetJmp = M.getFunction("llvm.setjmp"); + Function* LongJmp = M.getFunction("llvm.longjmp"); // This program doesn't have longjmp and setjmp calls. if ((!LongJmp || LongJmp->use_empty()) && diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp index db4387fa54..00cfc513b6 100644 --- a/lib/Transforms/IPO/StripSymbols.cpp +++ b/lib/Transforms/IPO/StripSymbols.cpp @@ -94,11 +94,11 @@ bool StripSymbols::runOnModule(Module &M) { // Strip debug info in the module if it exists. To do this, we remove // llvm.dbg.func.start, llvm.dbg.stoppoint, and llvm.dbg.region.end calls, and // any globals they point to if now dead. - Function *FuncStart = M.getNamedFunction("llvm.dbg.func.start"); - Function *StopPoint = M.getNamedFunction("llvm.dbg.stoppoint"); - Function *RegionStart = M.getNamedFunction("llvm.dbg.region.start"); - Function *RegionEnd = M.getNamedFunction("llvm.dbg.region.end"); - Function *Declare = M.getNamedFunction("llvm.dbg.declare"); + Function *FuncStart = M.getFunction("llvm.dbg.func.start"); + Function *StopPoint = M.getFunction("llvm.dbg.stoppoint"); + Function *RegionStart = M.getFunction("llvm.dbg.region.start"); + Function *RegionEnd = M.getFunction("llvm.dbg.region.end"); + Function *Declare = M.getFunction("llvm.dbg.declare"); if (!FuncStart && !StopPoint && !RegionStart && !RegionEnd && !Declare) return true; diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index add1bf01ef..23f2093499 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -45,7 +45,7 @@ ModulePass *llvm::createFunctionProfilerPass() { } bool FunctionProfiler::runOnModule(Module &M) { - Function *Main = M.getMainFunction(); + Function *Main = M.getFunction("main"); if (Main == 0) { cerr << "WARNING: cannot insert function profiling into a module" << " with no main function!\n"; @@ -88,7 +88,7 @@ namespace { ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); } bool BlockProfiler::runOnModule(Module &M) { - Function *Main = M.getMainFunction(); + Function *Main = M.getFunction("main"); if (Main == 0) { cerr << "WARNING: cannot insert block profiling into a module" << " with no main function!\n"; diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp index 97b5d5ca42..4960d3c206 100644 --- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -40,7 +40,7 @@ namespace { ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); } bool EdgeProfiler::runOnModule(Module &M) { - Function *Main = M.getMainFunction(); + Function *Main = M.getFunction("main"); if (Main == 0) { cerr << "WARNING: cannot insert edge profiling into a module" << " with no main function!\n"; diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp index 68e0d282cc..4c09fb61c5 100644 --- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp +++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp @@ -58,7 +58,7 @@ static void InsertInstrumentationCall (BasicBlock *BB, } bool TraceBasicBlocks::runOnModule(Module &M) { - Function *Main = M.getMainFunction(); + Function *Main = M.getFunction("main"); if (Main == 0) { cerr << "WARNING: cannot insert basic-block trace instrumentation" << " into a module with no main function!\n"; diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp index 7c88aa2902..20636d45a2 100644 --- a/lib/Transforms/Scalar/LowerGC.cpp +++ b/lib/Transforms/Scalar/LowerGC.cpp @@ -98,9 +98,9 @@ const StructType *LowerGC::getRootRecordType(unsigned NumRoots) { /// doInitialization - If this module uses the GC intrinsics, find them now. If /// not, this pass does not do anything. bool LowerGC::doInitialization(Module &M) { - GCRootInt = M.getNamedFunction("llvm.gcroot"); - GCReadInt = M.getNamedFunction("llvm.gcread"); - GCWriteInt = M.getNamedFunction("llvm.gcwrite"); + GCRootInt = M.getFunction("llvm.gcroot"); + GCReadInt = M.getFunction("llvm.gcread"); + GCWriteInt = M.getFunction("llvm.gcwrite"); if (!GCRootInt && !GCReadInt && !GCWriteInt) return false; PointerType *VoidPtr = PointerType::get(Type::Int8Ty); diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 163d8d2ac1..8aab595bd2 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -142,7 +142,7 @@ Constant *Module::getOrInsertFunction(const std::string &Name, ValueSymbolTable &SymTab = getValueSymbolTable(); // See if we have a definition for the specified function already. - Function *F = dyn_cast_or_null<Function>(SymTab.lookup(Name)); + GlobalValue *F = dyn_cast_or_null<GlobalValue>(SymTab.lookup(Name)); if (F == 0) { // Nope, add it Function *New = new Function(Ty, GlobalVariable::ExternalLinkage, Name); @@ -160,7 +160,7 @@ Constant *Module::getOrInsertFunction(const std::string &Name, // If the function exists but has the wrong type, return a bitcast to the // right type. - if (F->getFunctionType() != Ty) + if (F->getType() != PointerType::get(Ty)) return ConstantExpr::getBitCast(F, PointerType::get(Ty)); // Otherwise, we just found the existing function or a prototype. diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index b597d8256d..5596839979 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -194,7 +194,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { //if main isn't present, claim there is no problem if (KeepMain && find(Funcs.begin(), Funcs.end(), - BD.getProgram()->getMainFunction()) == Funcs.end()) + BD.getProgram()->getFunction("main")) == Funcs.end()) return false; // Clone the program to try hacking it apart... diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 38ccf0bc56..aed90cb80b 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -639,7 +639,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, // First, if the main function is in the Safe module, we must add a stub to // the Test module to call into it. Thus, we create a new function `main' // which just calls the old one. - if (Function *oldMain = Safe->getNamedFunction("main")) + if (Function *oldMain = Safe->getFunction("main")) if (!oldMain->isDeclaration()) { // Rename it oldMain->setName("llvm_bugpoint_old_main"); @@ -685,7 +685,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { if (F->isDeclaration() && !F->use_empty() && &*F != resolverFunc && F->getIntrinsicID() == 0 /* ignore intrinsics */) { - Function *TestFn = Test->getNamedFunction(F->getName()); + Function *TestFn = Test->getFunction(F->getName()); // Don't forward functions which are external in the test module too. if (TestFn && !TestFn->isDeclaration()) { diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 9f1ecc2978..c7b0765d52 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -103,7 +103,7 @@ int main(int argc, char **argv, char * const *envp) { // using the contents of Args to determine argc & argv, and the contents of // EnvVars to determine envp. // - Function *Fn = MP->getModule()->getMainFunction(); + Function *Fn = MP->getModule()->getFunction("main"); if (!Fn) { std::cerr << "'main' function not found in module.\n"; return -1; diff --git a/tools/llvm-upgrade/UpgradeParser.cpp.cvs b/tools/llvm-upgrade/UpgradeParser.cpp.cvs index 70ff399bbe..cee36df230 100644 --- a/tools/llvm-upgrade/UpgradeParser.cpp.cvs +++ b/tools/llvm-upgrade/UpgradeParser.cpp.cvs @@ -929,7 +929,7 @@ ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, if (const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType())) if (Function *OtherF = - CurModule.CurrentModule->getNamedFunction(DID.getName())) + CurModule.CurrentModule->getFunction(DID.getName())) if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) { V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy)); fixed = true; @@ -1677,10 +1677,10 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, //Not all functions use vaarg, so make a second check for ObsoleteVarArgs { Function* F; - if ((F = Result->getNamedFunction("llvm.va_start")) + if ((F = Result->getFunction("llvm.va_start")) && F->getFunctionType()->getNumParams() == 0) ObsoleteVarArgs = true; - if((F = Result->getNamedFunction("llvm.va_copy")) + if((F = Result->getFunction("llvm.va_copy")) && F->getFunctionType()->getNumParams() == 1) ObsoleteVarArgs = true; } @@ -1691,7 +1691,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, } if(ObsoleteVarArgs) { - if(Function* F = Result->getNamedFunction("llvm.va_start")) { + if(Function* F = Result->getFunction("llvm.va_start")) { if (F->arg_size() != 0) { error("Obsolete va_start takes 0 argument"); return 0; @@ -1720,7 +1720,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_end")) { + if(Function* F = Result->getFunction("llvm.va_end")) { if(F->arg_size() != 1) { error("Obsolete va_end takes 1 argument"); return 0; @@ -1746,7 +1746,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_copy")) { + if(Function* F = Result->getFunction("llvm.va_copy")) { if(F->arg_size() != 1) { error("Obsolete va_copy takes 1 argument"); return 0; diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y index 0f47b386ba..3091ea3ba2 100644 --- a/tools/llvm-upgrade/UpgradeParser.y +++ b/tools/llvm-upgrade/UpgradeParser.y @@ -569,7 +569,7 @@ ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, if (const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType())) if (Function *OtherF = - CurModule.CurrentModule->getNamedFunction(DID.getName())) + CurModule.CurrentModule->getFunction(DID.getName())) if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) { V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy)); fixed = true; @@ -1317,10 +1317,10 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, //Not all functions use vaarg, so make a second check for ObsoleteVarArgs { Function* F; - if ((F = Result->getNamedFunction("llvm.va_start")) + if ((F = Result->getFunction("llvm.va_start")) && F->getFunctionType()->getNumParams() == 0) ObsoleteVarArgs = true; - if((F = Result->getNamedFunction("llvm.va_copy")) + if((F = Result->getFunction("llvm.va_copy")) && F->getFunctionType()->getNumParams() == 1) ObsoleteVarArgs = true; } @@ -1331,7 +1331,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, } if(ObsoleteVarArgs) { - if(Function* F = Result->getNamedFunction("llvm.va_start")) { + if(Function* F = Result->getFunction("llvm.va_start")) { if (F->arg_size() != 0) { error("Obsolete va_start takes 0 argument"); return 0; @@ -1360,7 +1360,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_end")) { + if(Function* F = Result->getFunction("llvm.va_end")) { if(F->arg_size() != 1) { error("Obsolete va_end takes 1 argument"); return 0; @@ -1386,7 +1386,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_copy")) { + if(Function* F = Result->getFunction("llvm.va_copy")) { if(F->arg_size() != 1) { error("Obsolete va_copy takes 1 argument"); return 0; diff --git a/tools/llvm-upgrade/UpgradeParser.y.cvs b/tools/llvm-upgrade/UpgradeParser.y.cvs index 0f47b386ba..3091ea3ba2 100644 --- a/tools/llvm-upgrade/UpgradeParser.y.cvs +++ b/tools/llvm-upgrade/UpgradeParser.y.cvs @@ -569,7 +569,7 @@ ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, if (const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType())) if (Function *OtherF = - CurModule.CurrentModule->getNamedFunction(DID.getName())) + CurModule.CurrentModule->getFunction(DID.getName())) if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) { V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy)); fixed = true; @@ -1317,10 +1317,10 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, //Not all functions use vaarg, so make a second check for ObsoleteVarArgs { Function* F; - if ((F = Result->getNamedFunction("llvm.va_start")) + if ((F = Result->getFunction("llvm.va_start")) && F->getFunctionType()->getNumParams() == 0) ObsoleteVarArgs = true; - if((F = Result->getNamedFunction("llvm.va_copy")) + if((F = Result->getFunction("llvm.va_copy")) && F->getFunctionType()->getNumParams() == 1) ObsoleteVarArgs = true; } @@ -1331,7 +1331,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, } if(ObsoleteVarArgs) { - if(Function* F = Result->getNamedFunction("llvm.va_start")) { + if(Function* F = Result->getFunction("llvm.va_start")) { if (F->arg_size() != 0) { error("Obsolete va_start takes 0 argument"); return 0; @@ -1360,7 +1360,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_end")) { + if(Function* F = Result->getFunction("llvm.va_end")) { if(F->arg_size() != 1) { error("Obsolete va_end takes 1 argument"); return 0; @@ -1386,7 +1386,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in, Result->getFunctionList().erase(F); } - if(Function* F = Result->getNamedFunction("llvm.va_copy")) { + if(Function* F = Result->getFunction("llvm.va_copy")) { if(F->arg_size() != 1) { error("Obsolete va_copy takes 1 argument"); return 0; diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index e7d1185855..70f5626af0 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -1544,7 +1544,7 @@ void CppWriter::printFunctionBody(const Function *F) { } void CppWriter::printInline(const std::string& fname, const std::string& func) { - const Function* F = TheModule->getNamedFunction(func); + const Function* F = TheModule->getFunction(func); if (!F) { error(std::string("Function '") + func + "' not found in input module"); return; @@ -1719,7 +1719,7 @@ void CppWriter::printFunction( const std::string& fname, // Name of generated function const std::string& funcName // Name of function to generate ) { - const Function* F = TheModule->getNamedFunction(funcName); + const Function* F = TheModule->getFunction(funcName); if (!F) { error(std::string("Function '") + funcName + "' not found in input module"); return; |