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
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 6791f57..0fd6d46 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -54,7 +54,7 @@
 /// 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 d00e1f2..8186e7b 100644
--- a/lib/Linker/LinkArchives.cpp
+++ b/lib/Linker/LinkArchives.cpp
@@ -43,7 +43,7 @@
   // 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 0595b5c..f877184 100644
--- a/lib/Transforms/IPO/ExtractFunction.cpp
+++ b/lib/Transforms/IPO/ExtractFunction.cpp
@@ -33,7 +33,7 @@
 
     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 0d2f350..343fadb 100644
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/lib/Transforms/IPO/IndMemRemoval.cpp
@@ -44,7 +44,7 @@
   //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 @@
       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 54312b7..eebc70a 100644
--- a/lib/Transforms/IPO/Internalize.cpp
+++ b/lib/Transforms/IPO/Internalize.cpp
@@ -95,7 +95,7 @@
   // 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 a7da282..8941c8b 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -127,8 +127,8 @@
   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 db4387f..00cfc51 100644
--- a/lib/Transforms/IPO/StripSymbols.cpp
+++ b/lib/Transforms/IPO/StripSymbols.cpp
@@ -94,11 +94,11 @@
   // 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 add1bf0..23f2093 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -45,7 +45,7 @@
 }
 
 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 @@
 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 97b5d5c..4960d3c 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -40,7 +40,7 @@
 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 68e0d28..4c09fb6 100644
--- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
+++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
@@ -58,7 +58,7 @@
 }
 
 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 7c88aa2..20636d4 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -98,9 +98,9 @@
 /// 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 163d8d2..8aab595 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -142,7 +142,7 @@
   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 @@
 
   // 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.