OSDN Git Service

For PR411:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 5 Feb 2007 21:19:13 +0000 (21:19 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 5 Feb 2007 21:19:13 +0000 (21:19 +0000)
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

19 files changed:
lib/ExecutionEngine/ExecutionEngine.cpp
lib/Linker/LinkArchives.cpp
lib/Transforms/IPO/ExtractFunction.cpp
lib/Transforms/IPO/IndMemRemoval.cpp
lib/Transforms/IPO/Internalize.cpp
lib/Transforms/IPO/LowerSetJmp.cpp
lib/Transforms/IPO/StripSymbols.cpp
lib/Transforms/Instrumentation/BlockProfiling.cpp
lib/Transforms/Instrumentation/EdgeProfiling.cpp
lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
lib/Transforms/Scalar/LowerGC.cpp
lib/VMCore/Module.cpp
tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/Miscompilation.cpp
tools/lli/lli.cpp
tools/llvm-upgrade/UpgradeParser.cpp.cvs
tools/llvm-upgrade/UpgradeParser.y
tools/llvm-upgrade/UpgradeParser.y.cvs
tools/llvm2cpp/CppWriter.cpp

index 6791f57..0fd6d46 100644 (file)
@@ -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;
index d00e1f2..8186e7b 100644 (file)
@@ -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");
 
index 0595b5c..f877184 100644 (file)
@@ -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
       }
       
index 0d2f350..343fadb 100644 (file)
@@ -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(), 
index 54312b7..eebc70a 100644 (file)
@@ -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...
     
index a7da282..8941c8b 100644 (file)
@@ -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()) &&
index db4387f..00cfc51 100644 (file)
@@ -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;
 
index add1bf0..23f2093 100644 (file)
@@ -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";
index 97b5d5c..4960d3c 100644 (file)
@@ -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";
index 68e0d28..4c09fb6 100644 (file)
@@ -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";
index 7c88aa2..20636d4 100644 (file)
@@ -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);
index 163d8d2..8aab595 100644 (file)
@@ -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.
index b597d82..5596839 100644 (file)
@@ -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...
index 38ccf0b..aed90cb 100644 (file)
@@ -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()) {
index 9f1ecc2..c7b0765 100644 (file)
@@ -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;
index 70ff399..cee36df 100644 (file)
@@ -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;
index 0f47b38..3091ea3 100644 (file)
@@ -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;
index 0f47b38..3091ea3 100644 (file)
@@ -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;
index e7d1185..70f5626 100644 (file)
@@ -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;