diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-14 19:27:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-14 19:27:19 +0000 |
commit | be21ca54e08339ede5dd4bbb882182d22e274988 (patch) | |
tree | 3fc14c02ac5bbecec325cf6451f776ddefd91f82 /tools/bugpoint/CodeGeneratorBug.cpp | |
parent | 39354c99a158685d8bc91b0836c283e936a29cb2 (diff) |
Refactor all of the "splitting a module into two pieces" code to avoid
code duplication. Also, don't use ReduceMiscompilingFunctions::TestFuncs
to print out the final message.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12387 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/CodeGeneratorBug.cpp')
-rw-r--r-- | tools/bugpoint/CodeGeneratorBug.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/tools/bugpoint/CodeGeneratorBug.cpp b/tools/bugpoint/CodeGeneratorBug.cpp index 4da709a3f8..449aadd62f 100644 --- a/tools/bugpoint/CodeGeneratorBug.cpp +++ b/tools/bugpoint/CodeGeneratorBug.cpp @@ -63,40 +63,15 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs, std::cout << "\t"; // Clone the module for the two halves of the program we want. - Module *SafeModule = CloneModule(BD.Program); - - // Make sure functions & globals are all external so that linkage - // between the two modules will work. - for (Module::iterator I = SafeModule->begin(), E = SafeModule->end();I!=E;++I) - I->setLinkage(GlobalValue::ExternalLinkage); - for (Module::giterator I=SafeModule->gbegin(),E = SafeModule->gend();I!=E;++I) - I->setLinkage(GlobalValue::ExternalLinkage); - - Module *TestModule = CloneModule(SafeModule); - - // Make sure global initializers exist only in the safe module (CBE->.so) - for (Module::giterator I=TestModule->gbegin(),E = TestModule->gend();I!=E;++I) - I->setInitializer(0); // Delete the initializer to make it external - - // Remove the Test functions from the Safe module - for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { - Function *TNOF = SafeModule->getFunction(Funcs[i]->getName(), - Funcs[i]->getFunctionType()); - DEBUG(std::cerr << "Removing function " << Funcs[i]->getName() << "\n"); - assert(TNOF && "Function doesn't exist in module!"); - DeleteFunctionBody(TNOF); // Function is now external in this module! - } - - // Remove the Safe functions from the Test module - for (Module::iterator I=TestModule->begin(),E=TestModule->end(); I!=E; ++I) { - bool funcFound = false; - for (std::vector<Function*>::const_iterator F=Funcs.begin(),Fe=Funcs.end(); - F != Fe; ++F) - if (I->getName() == (*F)->getName()) funcFound = true; + Module *SafeModule = CloneModule(BD.getProgram()); - if (!funcFound && !(BD.isExecutingJIT() && I->getName() == "main")) - DeleteFunctionBody(I); + // The JIT must extract the 'main' function. + std::vector<Function*> RealFuncs(Funcs); + if (BD.isExecutingJIT()) { + if (Function *F = BD.Program->getMainFunction()) + RealFuncs.push_back(F); } + Module *TestModule = SplitFunctionsOutOfModule(SafeModule, RealFuncs); // This is only applicable if we are debugging the JIT: // Find all external functions in the Safe modules that are actually used |