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
This commit is contained in:
Reid Spencer 2007-02-05 21:19:13 +00:00
parent cdedc3b336
commit 688b0490e2
19 changed files with 46 additions and 46 deletions

View 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;

View 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");

View 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
}

View 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(),

View 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...

View 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()) &&

View 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;

View 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";

View 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";

View 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";

View 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);

View 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.

View 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...

View 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()) {

View 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;

View 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;

View 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;

View 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;

View 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;