Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
//===- CodeGeneratorBug.cpp - Debug code generation bugs ------------------===//
|
|
|
|
//
|
|
|
|
// This file implements program code generation debugging support.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "BugDriver.h"
|
|
|
|
#include "ListReducer.h"
|
2003-07-28 19:16:14 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
|
|
|
#include "llvm/GlobalValue.h"
|
|
|
|
#include "llvm/iMemory.h"
|
|
|
|
#include "llvm/iTerminators.h"
|
|
|
|
#include "llvm/iOther.h"
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
#include "llvm/Module.h"
|
2003-07-28 19:16:14 +00:00
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "llvm/Analysis/Verifier.h"
|
2003-07-28 21:07:39 +00:00
|
|
|
#include "llvm/Support/Mangler.h"
|
2003-07-28 19:16:14 +00:00
|
|
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
#include "llvm/Transforms/Utils/Cloning.h"
|
|
|
|
#include "llvm/Transforms/Utils/Linker.h"
|
2003-07-30 20:15:56 +00:00
|
|
|
#include "Support/CommandLine.h"
|
2003-08-01 22:13:59 +00:00
|
|
|
#include "Support/Debug.h"
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
#include "Support/StringExtras.h"
|
2003-08-07 21:42:28 +00:00
|
|
|
#include "Support/FileUtilities.h"
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <set>
|
|
|
|
|
2003-07-30 20:15:56 +00:00
|
|
|
extern cl::list<std::string> InputArgv;
|
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
class ReduceMisCodegenFunctions : public ListReducer<Function*> {
|
|
|
|
BugDriver &BD;
|
|
|
|
public:
|
|
|
|
ReduceMisCodegenFunctions(BugDriver &bd) : BD(bd) {}
|
|
|
|
|
|
|
|
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
|
|
|
std::vector<Function*> &Suffix) {
|
|
|
|
if (!Prefix.empty() && TestFuncs(Prefix))
|
|
|
|
return KeepPrefix;
|
|
|
|
if (!Suffix.empty() && TestFuncs(Suffix))
|
|
|
|
return KeepSuffix;
|
|
|
|
return NoFailure;
|
|
|
|
}
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
bool TestFuncs(const std::vector<Function*> &CodegenTest,
|
|
|
|
bool KeepFiles = false);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
2003-10-14 21:59:36 +00:00
|
|
|
bool KeepFiles) {
|
2003-07-30 20:15:56 +00:00
|
|
|
std::cout << "Testing functions: ";
|
|
|
|
BD.PrintFunctionList(Funcs);
|
|
|
|
std::cout << "\t";
|
2003-07-28 19:16:14 +00:00
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
// 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
|
|
|
|
|
2003-07-24 21:59:10 +00:00
|
|
|
// Remove the Test functions from the Safe module
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
|
|
|
|
Function *TNOF = SafeModule->getFunction(Funcs[i]->getName(),
|
|
|
|
Funcs[i]->getFunctionType());
|
2003-07-29 16:02:28 +00:00
|
|
|
DEBUG(std::cerr << "Removing function " << Funcs[i]->getName() << "\n");
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
assert(TNOF && "Function doesn't exist in module!");
|
|
|
|
DeleteFunctionBody(TNOF); // Function is now external in this module!
|
|
|
|
}
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
if (!funcFound && !(BD.isExecutingJIT() && I->getName() == "main"))
|
|
|
|
DeleteFunctionBody(I);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is only applicable if we are debugging the JIT:
|
|
|
|
// Find all external functions in the Safe modules that are actually used
|
|
|
|
// (called or taken address of), and make them call the JIT wrapper instead
|
|
|
|
if (BD.isExecutingJIT()) {
|
|
|
|
// Must delete `main' from Safe module if it has it
|
2003-07-28 21:07:39 +00:00
|
|
|
Function *safeMain = SafeModule->getNamedFunction("main");
|
2003-07-29 16:02:28 +00:00
|
|
|
assert(safeMain && "`main' function not found in safe module!");
|
2003-07-28 21:07:39 +00:00
|
|
|
DeleteFunctionBody(safeMain);
|
2003-07-28 19:16:14 +00:00
|
|
|
|
|
|
|
// Add an external function "getPointerToNamedFunction" that JIT provides
|
|
|
|
// Prototype: void *getPointerToNamedFunction(const char* Name)
|
|
|
|
std::vector<const Type*> Params;
|
|
|
|
Params.push_back(PointerType::get(Type::SByteTy)); // std::string&
|
|
|
|
FunctionType *resolverTy = FunctionType::get(PointerType::get(Type::VoidTy),
|
|
|
|
Params, false /* isVarArg */);
|
|
|
|
Function *resolverFunc = new Function(resolverTy,
|
|
|
|
GlobalValue::ExternalLinkage,
|
2003-07-28 21:07:39 +00:00
|
|
|
"getPointerToNamedFunction",
|
2003-07-28 19:16:14 +00:00
|
|
|
SafeModule);
|
|
|
|
|
|
|
|
// Use the function we just added to get addresses of functions we need
|
|
|
|
// Iterate over the global declarations in the Safe module
|
|
|
|
for (Module::iterator F=SafeModule->begin(),E=SafeModule->end(); F!=E; ++F){
|
2003-10-19 23:32:50 +00:00
|
|
|
if (F->isExternal() && !F->use_empty() && &*F != resolverFunc &&
|
|
|
|
F->getIntrinsicID() == 0 /* ignore intrinsics */ &&
|
|
|
|
// Don't forward functions which are external in the test module too.
|
|
|
|
!TestModule->getNamedFunction(F->getName())->isExternal()) {
|
2003-07-28 19:16:14 +00:00
|
|
|
// If it has a non-zero use list,
|
|
|
|
// 1. Add a string constant with its name to the global file
|
|
|
|
// The correct type is `const [ NUM x sbyte ]' where NUM is length of
|
|
|
|
// function name + 1
|
|
|
|
const std::string &Name = F->getName();
|
|
|
|
GlobalVariable *funcName =
|
|
|
|
new GlobalVariable(ArrayType::get(Type::SByteTy, Name.length()+1),
|
|
|
|
true /* isConstant */,
|
|
|
|
GlobalValue::InternalLinkage,
|
|
|
|
ConstantArray::get(Name),
|
|
|
|
Name + "_name",
|
|
|
|
SafeModule);
|
|
|
|
|
|
|
|
// 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an
|
|
|
|
// sbyte* so it matches the signature of the resolver function.
|
2003-07-28 21:07:39 +00:00
|
|
|
std::vector<Constant*> GEPargs(2, Constant::getNullValue(Type::LongTy));
|
2003-07-28 19:16:14 +00:00
|
|
|
|
|
|
|
// 3. Replace all uses of `func' with calls to resolver by:
|
|
|
|
// (a) Iterating through the list of uses of this function
|
|
|
|
// (b) Insert a cast instruction in front of each use
|
|
|
|
// (c) Replace use of old call with new call
|
|
|
|
|
2003-07-28 21:07:39 +00:00
|
|
|
// GetElementPtr *funcName, ulong 0, ulong 0
|
|
|
|
Value *GEP =
|
|
|
|
ConstantExpr::getGetElementPtr(ConstantPointerRef::get(funcName),
|
|
|
|
GEPargs);
|
|
|
|
std::vector<Value*> ResolverArgs;
|
|
|
|
ResolverArgs.push_back(GEP);
|
2003-07-28 19:16:14 +00:00
|
|
|
|
2003-07-28 21:07:39 +00:00
|
|
|
// Insert code at the beginning of the function
|
2003-10-19 21:48:27 +00:00
|
|
|
while (!F->use_empty())
|
|
|
|
if (Instruction *Inst = dyn_cast<Instruction>(F->use_back())) {
|
2003-07-28 19:16:14 +00:00
|
|
|
// call resolver(GetElementPtr...)
|
|
|
|
CallInst *resolve = new CallInst(resolverFunc, ResolverArgs,
|
|
|
|
"resolver", Inst);
|
|
|
|
// cast the result from the resolver to correctly-typed function
|
|
|
|
CastInst *castResolver =
|
|
|
|
new CastInst(resolve, PointerType::get(F->getFunctionType()),
|
2003-07-30 20:15:56 +00:00
|
|
|
"resolverCast", Inst);
|
2003-07-28 19:16:14 +00:00
|
|
|
// actually use the resolved function
|
|
|
|
Inst->replaceUsesOfWith(F, castResolver);
|
2003-07-28 21:07:39 +00:00
|
|
|
} else {
|
|
|
|
// FIXME: need to take care of cases where a function is used that
|
|
|
|
// is not an instruction, e.g. global variable initializer...
|
|
|
|
std::cerr << "Non-instruction is using an external function!\n";
|
|
|
|
abort();
|
2003-07-28 19:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-01 16:14:33 +00:00
|
|
|
if (verifyModule(*SafeModule) || verifyModule(*TestModule)) {
|
|
|
|
std::cerr << "Bugpoint has a bug, an corrupted a module!!\n";
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2003-07-28 21:07:39 +00:00
|
|
|
DEBUG(std::cerr << "Safe module:\n";
|
|
|
|
typedef Module::iterator MI;
|
|
|
|
typedef Module::giterator MGI;
|
2003-07-28 19:16:14 +00:00
|
|
|
|
2003-07-28 21:07:39 +00:00
|
|
|
for (MI I = SafeModule->begin(), E = SafeModule->end(); I != E; ++I)
|
|
|
|
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
|
|
|
|
for (MGI I = SafeModule->gbegin(), E = SafeModule->gend(); I!=E; ++I)
|
|
|
|
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
|
|
|
|
|
|
|
|
std::cerr << "Test module:\n";
|
|
|
|
for (MI I = TestModule->begin(), E = TestModule->end(); I != E; ++I)
|
|
|
|
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
|
|
|
|
for (MGI I=TestModule->gbegin(),E = TestModule->gend(); I!= E; ++I)
|
|
|
|
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
|
|
|
|
);
|
2003-07-28 19:16:14 +00:00
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
// Write out the bytecode to be sent to CBE
|
2003-07-28 19:16:14 +00:00
|
|
|
std::string SafeModuleBC = getUniqueFilename("bugpoint.safe.bc");
|
2003-08-01 16:14:33 +00:00
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
if (BD.writeProgramToFile(SafeModuleBC, SafeModule)) {
|
|
|
|
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove all functions from the Test module EXCEPT for the ones specified in
|
|
|
|
// Funcs. We know which ones these are because they are non-external in
|
|
|
|
// ToOptimize, but external in ToNotOptimize.
|
|
|
|
//
|
|
|
|
for (Module::iterator I = TestModule->begin(), E = TestModule->end();I!=E;++I)
|
|
|
|
if (!I->isExternal()) {
|
|
|
|
Function *TNOF = SafeModule->getFunction(I->getName(),
|
|
|
|
I->getFunctionType());
|
|
|
|
assert(TNOF && "Function doesn't exist in ToNotOptimize module??");
|
|
|
|
if (!TNOF->isExternal())
|
|
|
|
DeleteFunctionBody(I);
|
|
|
|
}
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
std::string TestModuleBC = getUniqueFilename("bugpoint.test.bc");
|
|
|
|
if (verifyModule(*TestModule)) {
|
|
|
|
std::cerr << "Bytecode file corrupted!\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
2003-08-03 22:29:43 +00:00
|
|
|
|
|
|
|
// Clean up the modules, removing extra cruft that we don't need anymore...
|
|
|
|
SafeModule = BD.performFinalCleanups(SafeModule);
|
|
|
|
TestModule = BD.performFinalCleanups(TestModule);
|
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
if (BD.writeProgramToFile(TestModuleBC, TestModule)) {
|
|
|
|
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2003-08-03 22:29:43 +00:00
|
|
|
// Make a shared library
|
2003-10-14 21:59:36 +00:00
|
|
|
std::string SharedObject = BD.compileSharedObject(SafeModuleBC);
|
2003-08-03 22:29:43 +00:00
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
delete SafeModule;
|
|
|
|
delete TestModule;
|
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
// Run the code generator on the `Test' code, loading the shared library.
|
|
|
|
// The function returns whether or not the new output differs from reference.
|
2003-08-04 00:56:27 +00:00
|
|
|
int Result = BD.diffProgram(TestModuleBC, SharedObject, false);
|
|
|
|
|
|
|
|
if (Result)
|
2003-08-07 21:05:13 +00:00
|
|
|
std::cerr << ": still failing!\n";
|
2003-08-04 00:56:27 +00:00
|
|
|
else
|
|
|
|
std::cerr << ": didn't fail.\n";
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
if (KeepFiles) {
|
2003-08-04 00:56:27 +00:00
|
|
|
std::cout << "You can reproduce the problem with the command line: \n";
|
|
|
|
if (BD.isExecutingJIT()) {
|
|
|
|
std::cout << " lli -load " << SharedObject << " " << TestModuleBC;
|
|
|
|
} else {
|
|
|
|
std::cout << " llc " << TestModuleBC << " -o " << TestModuleBC << ".s\n";
|
|
|
|
std::cout << " gcc " << SharedObject << " " << TestModuleBC
|
2003-10-18 21:55:47 +00:00
|
|
|
<< ".s -o " << TestModuleBC << ".exe -Wl,-R.\n";
|
2003-08-04 00:56:27 +00:00
|
|
|
std::cout << " " << TestModuleBC << ".exe";
|
|
|
|
}
|
2003-07-30 20:15:56 +00:00
|
|
|
for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
|
|
|
|
std::cout << " " << InputArgv[i];
|
|
|
|
std::cout << "\n";
|
2003-08-28 22:14:16 +00:00
|
|
|
std::cout << "The shared object was created with:\n llvm-dis -c "
|
2003-08-17 22:08:25 +00:00
|
|
|
<< SafeModuleBC << " -o temporary.c\n"
|
2003-08-17 23:38:53 +00:00
|
|
|
<< " gcc -xc temporary.c -O2 -o " << SharedObject
|
|
|
|
#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
2003-10-14 20:55:56 +00:00
|
|
|
<< " -G" // Compile a shared library, `-G' for Sparc
|
2003-10-14 21:01:51 +00:00
|
|
|
#else
|
|
|
|
<< " -shared" // `-shared' for Linux/X86, maybe others
|
2003-08-17 23:38:53 +00:00
|
|
|
#endif
|
2003-10-18 21:08:57 +00:00
|
|
|
<< " -fno-strict-aliasing\n";
|
2003-07-28 19:16:14 +00:00
|
|
|
} else {
|
|
|
|
removeFile(TestModuleBC);
|
|
|
|
removeFile(SafeModuleBC);
|
|
|
|
removeFile(SharedObject);
|
|
|
|
}
|
2003-07-24 21:59:10 +00:00
|
|
|
return Result;
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
2003-07-24 21:59:10 +00:00
|
|
|
struct Disambiguator {
|
2003-07-28 19:16:14 +00:00
|
|
|
std::set<std::string> SymbolNames;
|
|
|
|
std::set<GlobalValue*> Symbols;
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
uint64_t uniqueCounter;
|
|
|
|
bool externalOnly;
|
2003-07-24 21:59:10 +00:00
|
|
|
public:
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
Disambiguator() : uniqueCounter(0), externalOnly(true) {}
|
|
|
|
void setExternalOnly(bool value) { externalOnly = value; }
|
2003-07-24 21:59:10 +00:00
|
|
|
void add(GlobalValue &V) {
|
2003-07-28 19:16:14 +00:00
|
|
|
// If we're only processing externals and this isn't external, bail
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
if (externalOnly && !V.isExternal()) return;
|
2003-07-28 19:16:14 +00:00
|
|
|
// If we're already processed this symbol, don't add it again
|
|
|
|
if (Symbols.count(&V) != 0) return;
|
2003-07-30 21:45:20 +00:00
|
|
|
// Ignore intrinsic functions
|
|
|
|
if (Function *F = dyn_cast<Function>(&V))
|
|
|
|
if (F->getIntrinsicID() != 0)
|
|
|
|
return;
|
2003-07-28 19:16:14 +00:00
|
|
|
|
|
|
|
std::string SymName = V.getName();
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
|
2003-07-28 21:07:39 +00:00
|
|
|
// Use the Mangler facility to make symbol names that will be valid in
|
|
|
|
// shared objects.
|
|
|
|
SymName = Mangler::makeNameProper(SymName);
|
|
|
|
V.setName(SymName);
|
2003-07-28 19:16:14 +00:00
|
|
|
|
|
|
|
if (SymbolNames.count(SymName) == 0) {
|
|
|
|
DEBUG(std::cerr << "Disambiguator: adding " << SymName
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
<< ", no conflicts.\n");
|
2003-07-28 19:16:14 +00:00
|
|
|
SymbolNames.insert(SymName);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
} else {
|
|
|
|
// Mangle name before adding
|
|
|
|
std::string newName;
|
|
|
|
do {
|
2003-07-28 19:16:14 +00:00
|
|
|
newName = SymName + "_" + utostr(uniqueCounter);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
if (SymbolNames.count(newName) == 0) break;
|
|
|
|
else ++uniqueCounter;
|
|
|
|
} while (1);
|
|
|
|
//while (SymbolNames.count(V->getName()+utostr(uniqueCounter++))==0);
|
2003-07-28 19:16:14 +00:00
|
|
|
DEBUG(std::cerr << "Disambiguator: conflict: " << SymName
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
<< ", adding: " << newName << "\n");
|
|
|
|
V.setName(newName);
|
|
|
|
SymbolNames.insert(newName);
|
|
|
|
}
|
2003-07-28 19:16:14 +00:00
|
|
|
Symbols.insert(&V);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2003-07-29 16:02:28 +00:00
|
|
|
void DisambiguateGlobalSymbols(Module *M) {
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
// First, try not to cause collisions by minimizing chances of renaming an
|
|
|
|
// already-external symbol, so take in external globals and functions as-is.
|
2003-07-24 21:59:10 +00:00
|
|
|
Disambiguator D;
|
2003-07-28 19:16:14 +00:00
|
|
|
DEBUG(std::cerr << "Disambiguating globals (external-only)\n");
|
2003-07-24 21:59:10 +00:00
|
|
|
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) D.add(*I);
|
2003-07-28 19:16:14 +00:00
|
|
|
DEBUG(std::cerr << "Disambiguating functions (external-only)\n");
|
2003-07-24 21:59:10 +00:00
|
|
|
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) D.add(*I);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
|
|
|
|
// Now just rename functions and globals as necessary, keeping what's already
|
|
|
|
// in the set unique.
|
|
|
|
D.setExternalOnly(false);
|
2003-07-28 19:16:14 +00:00
|
|
|
DEBUG(std::cerr << "Disambiguating globals\n");
|
2003-07-24 21:59:10 +00:00
|
|
|
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) D.add(*I);
|
2003-07-28 19:16:14 +00:00
|
|
|
DEBUG(std::cerr << "Disambiguating globals\n");
|
2003-07-24 21:59:10 +00:00
|
|
|
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) D.add(*I);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool BugDriver::debugCodeGenerator() {
|
|
|
|
// See if we can pin down which functions are being miscompiled...
|
|
|
|
//First, build a list of all of the non-external functions in the program.
|
|
|
|
std::vector<Function*> MisCodegenFunctions;
|
|
|
|
for (Module::iterator I = Program->begin(), E = Program->end(); I != E; ++I)
|
|
|
|
if (!I->isExternal())
|
|
|
|
MisCodegenFunctions.push_back(I);
|
|
|
|
|
2003-07-28 19:16:14 +00:00
|
|
|
// If we are executing the JIT, we *must* keep the function `main' in the
|
|
|
|
// module that is passed in, and not the shared library. However, we still
|
|
|
|
// want to be able to debug the `main' function alone. Thus, we create a new
|
|
|
|
// function `main' which just calls the old one.
|
|
|
|
if (isExecutingJIT()) {
|
|
|
|
// Get the `main' function
|
|
|
|
Function *oldMain = Program->getNamedFunction("main");
|
2003-07-29 16:02:28 +00:00
|
|
|
assert(oldMain && "`main' function not found in program!");
|
2003-07-28 19:16:14 +00:00
|
|
|
// Rename it
|
2003-08-07 21:05:13 +00:00
|
|
|
oldMain->setName("llvm_old_main");
|
2003-07-28 19:16:14 +00:00
|
|
|
// Create a NEW `main' function with same type
|
|
|
|
Function *newMain = new Function(oldMain->getFunctionType(),
|
2003-07-28 21:07:39 +00:00
|
|
|
GlobalValue::ExternalLinkage,
|
2003-07-28 19:16:14 +00:00
|
|
|
"main", Program);
|
|
|
|
// Call the old main function and return its result
|
|
|
|
BasicBlock *BB = new BasicBlock("entry", newMain);
|
|
|
|
std::vector<Value*> args;
|
2003-08-17 22:14:20 +00:00
|
|
|
for (Function::aiterator I = newMain->abegin(), E = newMain->aend(),
|
|
|
|
OI = oldMain->abegin(); I != E; ++I, ++OI) {
|
|
|
|
I->setName(OI->getName()); // Copy argument names from oldMain
|
2003-07-28 19:16:14 +00:00
|
|
|
args.push_back(I);
|
2003-08-17 22:14:20 +00:00
|
|
|
}
|
2003-07-28 19:16:14 +00:00
|
|
|
CallInst *call = new CallInst(oldMain, args);
|
|
|
|
BB->getInstList().push_back(call);
|
|
|
|
|
|
|
|
// if the type of old function wasn't void, return value of call
|
|
|
|
ReturnInst *ret;
|
|
|
|
if (oldMain->getReturnType() != Type::VoidTy) {
|
|
|
|
ret = new ReturnInst(call);
|
|
|
|
} else {
|
|
|
|
ret = new ReturnInst();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the return instruction to the BasicBlock
|
|
|
|
BB->getInstList().push_back(ret);
|
|
|
|
}
|
|
|
|
|
2003-07-29 16:02:28 +00:00
|
|
|
DisambiguateGlobalSymbols(Program);
|
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
// Do the reduction...
|
2003-07-30 20:15:56 +00:00
|
|
|
if (!ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions)) {
|
2003-08-04 00:56:27 +00:00
|
|
|
std::cerr << "*** Execution matches reference output! "
|
|
|
|
<< "bugpoint can't help you with your problem!\n";
|
2003-07-30 20:15:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
|
|
|
|
std::cout << "\n*** The following functions are being miscompiled: ";
|
|
|
|
PrintFunctionList(MisCodegenFunctions);
|
|
|
|
std::cout << "\n";
|
|
|
|
|
|
|
|
// Output a bunch of bytecode files for the user...
|
2003-07-28 19:16:14 +00:00
|
|
|
ReduceMisCodegenFunctions(*this).TestFuncs(MisCodegenFunctions, true);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
llvm-svn: 7293
2003-07-24 18:17:43 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|