2002-12-24 07:50:16 +08:00
|
|
|
//===- ExecutionDriver.cpp - Allow execution of LLVM program --------------===//
|
|
|
|
//
|
|
|
|
// This file contains code used to execute the program utilizing one of the
|
|
|
|
// various ways of running LLVM bytecode.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/*
|
|
|
|
BUGPOINT NOTES:
|
|
|
|
|
|
|
|
1. Bugpoint should not leave any files behind if the program works properly
|
|
|
|
2. There should be an option to specify the program name, which specifies a
|
|
|
|
unique string to put into output files. This allows operation in the
|
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-25 02:17:43 +08:00
|
|
|
SingleSource directory, e.g. default to the first input filename.
|
2002-12-24 07:50:16 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "BugDriver.h"
|
|
|
|
#include "Support/CommandLine.h"
|
2003-08-02 06:13:59 +08:00
|
|
|
#include "Support/Debug.h"
|
2003-08-02 04:29:45 +08:00
|
|
|
#include "Support/FileUtilities.h"
|
2003-08-08 05:19:30 +08:00
|
|
|
#include "Support/SystemUtils.h"
|
2003-10-07 21:45:51 +08:00
|
|
|
#include "llvm/Support/ToolRunner.h"
|
2002-12-24 07:50:16 +08:00
|
|
|
#include <fstream>
|
2002-12-24 08:44:34 +08:00
|
|
|
#include <iostream>
|
2002-12-24 07:50:16 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
// OutputType - Allow the user to specify the way code should be run, to test
|
|
|
|
// for miscompilation.
|
|
|
|
//
|
|
|
|
enum OutputType {
|
|
|
|
RunLLI, RunJIT, RunLLC, RunCBE
|
|
|
|
};
|
2003-09-30 06:40:52 +08:00
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
cl::opt<OutputType>
|
|
|
|
InterpreterSel(cl::desc("Specify how LLVM code should be executed:"),
|
2003-10-19 04:30:48 +08:00
|
|
|
cl::values(clEnumValN(RunLLI, "run-int", "Execute with the interpreter"),
|
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-25 02:17:43 +08:00
|
|
|
clEnumValN(RunJIT, "run-jit", "Execute with JIT"),
|
|
|
|
clEnumValN(RunLLC, "run-llc", "Compile with LLC"),
|
|
|
|
clEnumValN(RunCBE, "run-cbe", "Compile with CBE"),
|
2003-10-19 04:18:20 +08:00
|
|
|
0),
|
|
|
|
cl::init(RunCBE));
|
2003-04-24 04:31:37 +08:00
|
|
|
|
|
|
|
cl::opt<std::string>
|
|
|
|
InputFile("input", cl::init("/dev/null"),
|
|
|
|
cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
|
2003-10-15 06:24:31 +08:00
|
|
|
|
|
|
|
cl::list<std::string>
|
|
|
|
AdditionalSOs("additional-so",
|
|
|
|
cl::desc("Additional shared objects to load "
|
|
|
|
"into executing programs"));
|
2002-12-24 07:50:16 +08:00
|
|
|
}
|
|
|
|
|
2003-07-31 04:15:44 +08:00
|
|
|
// Anything specified after the --args option are taken as arguments to the
|
|
|
|
// program being debugged.
|
|
|
|
cl::list<std::string>
|
|
|
|
InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
|
|
|
|
cl::ZeroOrMore);
|
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// BugDriver method implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
/// initializeExecutionEnvironment - This method is used to set up the
|
|
|
|
/// environment for executing LLVM programs.
|
|
|
|
///
|
|
|
|
bool BugDriver::initializeExecutionEnvironment() {
|
|
|
|
std::cout << "Initializing execution environment: ";
|
|
|
|
|
|
|
|
// FIXME: This should default to searching for the best interpreter to use on
|
|
|
|
// this platform, which would be JIT, then LLC, then CBE, then LLI.
|
|
|
|
|
2003-09-30 06:40:52 +08:00
|
|
|
// Create an instance of the AbstractInterpreter interface as specified on
|
|
|
|
// the command line
|
2002-12-24 07:50:16 +08:00
|
|
|
std::string Message;
|
2003-05-03 11:19:41 +08:00
|
|
|
switch (InterpreterSel) {
|
2003-10-15 05:59:36 +08:00
|
|
|
case RunLLI:
|
|
|
|
Interpreter = AbstractInterpreter::createLLI(getToolName(), Message);
|
|
|
|
break;
|
|
|
|
case RunLLC:
|
|
|
|
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message);
|
|
|
|
break;
|
|
|
|
case RunJIT:
|
|
|
|
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message);
|
|
|
|
break;
|
|
|
|
case RunCBE:
|
|
|
|
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message);
|
|
|
|
break;
|
2003-05-03 11:19:41 +08:00
|
|
|
default:
|
2003-09-30 06:40:52 +08:00
|
|
|
Message = "Sorry, this back-end is not supported by bugpoint right now!\n";
|
2003-05-03 11:19:41 +08:00
|
|
|
break;
|
2002-12-24 07:50:16 +08:00
|
|
|
}
|
2003-09-30 06:40:52 +08:00
|
|
|
std::cerr << Message;
|
2002-12-24 07:50:16 +08:00
|
|
|
|
2003-07-25 05:59:10 +08:00
|
|
|
// Initialize auxiliary tools for debugging
|
2003-10-15 05:59:36 +08:00
|
|
|
cbe = AbstractInterpreter::createCBE(getToolName(), Message);
|
2003-07-25 05:59:10 +08:00
|
|
|
if (!cbe) { std::cout << Message << "\nExiting.\n"; exit(1); }
|
2003-10-15 05:59:36 +08:00
|
|
|
gcc = GCC::create(getToolName(), Message);
|
2003-07-25 05:59:10 +08:00
|
|
|
if (!gcc) { std::cout << Message << "\nExiting.\n"; exit(1); }
|
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
// If there was an error creating the selected interpreter, quit with error.
|
|
|
|
return Interpreter == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// executeProgram - This method runs "Program", capturing the output of the
|
|
|
|
/// program to a file, returning the filename of the file. A recommended
|
|
|
|
/// filename may be optionally specified.
|
|
|
|
///
|
|
|
|
std::string BugDriver::executeProgram(std::string OutputFile,
|
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-25 02:17:43 +08:00
|
|
|
std::string BytecodeFile,
|
2003-10-15 05:59:36 +08:00
|
|
|
const std::string &SharedObj,
|
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-25 02:17:43 +08:00
|
|
|
AbstractInterpreter *AI) {
|
2003-10-15 05:59:36 +08:00
|
|
|
if (AI == 0) AI = Interpreter;
|
|
|
|
assert(AI && "Interpreter should have been created already!");
|
2002-12-24 07:50:16 +08:00
|
|
|
bool CreatedBytecode = false;
|
|
|
|
if (BytecodeFile.empty()) {
|
|
|
|
// Emit the program to a bytecode file...
|
|
|
|
BytecodeFile = getUniqueFilename("bugpoint-test-program.bc");
|
|
|
|
|
|
|
|
if (writeProgramToFile(BytecodeFile, Program)) {
|
|
|
|
std::cerr << ToolName << ": Error emitting bytecode to file '"
|
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-25 02:17:43 +08:00
|
|
|
<< BytecodeFile << "'!\n";
|
2002-12-24 07:50:16 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
CreatedBytecode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
|
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-25 02:17:43 +08:00
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
// Check to see if this is a valid output filename...
|
|
|
|
OutputFile = getUniqueFilename(OutputFile);
|
|
|
|
|
2003-10-15 05:59:36 +08:00
|
|
|
// Figure out which shared objects to run, if any.
|
2003-10-15 06:24:31 +08:00
|
|
|
std::vector<std::string> SharedObjs(AdditionalSOs);
|
2003-10-15 05:59:36 +08:00
|
|
|
if (!SharedObj.empty())
|
|
|
|
SharedObjs.push_back(SharedObj);
|
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
// Actually execute the program!
|
2003-10-15 05:59:36 +08:00
|
|
|
int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
|
|
|
|
OutputFile, SharedObjs);
|
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
|
|
|
|
// Remove the temporary bytecode file.
|
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-25 02:17:43 +08:00
|
|
|
if (CreatedBytecode) removeFile(BytecodeFile);
|
2002-12-24 07:50:16 +08:00
|
|
|
|
|
|
|
// Return the filename we captured the output to.
|
|
|
|
return OutputFile;
|
|
|
|
}
|
|
|
|
|
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-25 02:17:43 +08:00
|
|
|
|
2003-10-15 05:09:11 +08:00
|
|
|
std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
|
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-25 02:17:43 +08:00
|
|
|
assert(Interpreter && "Interpreter should have been created already!");
|
2003-10-15 05:09:11 +08:00
|
|
|
std::string OutputCFile;
|
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-25 02:17:43 +08:00
|
|
|
|
|
|
|
// Using CBE
|
|
|
|
cbe->OutputC(BytecodeFile, OutputCFile);
|
|
|
|
|
|
|
|
#if 0 /* This is an alternative, as yet unimplemented */
|
|
|
|
// Using LLC
|
2003-10-15 05:09:11 +08:00
|
|
|
std::string Message;
|
2003-09-30 06:40:52 +08:00
|
|
|
LLC *llc = createLLCtool(Message);
|
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-25 02:17:43 +08:00
|
|
|
if (llc->OutputAsm(BytecodeFile, OutputFile)) {
|
|
|
|
std::cerr << "Could not generate asm code with `llc', exiting.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-10-15 05:09:11 +08:00
|
|
|
std::string SharedObjectFile;
|
2003-10-15 05:59:36 +08:00
|
|
|
if (gcc->MakeSharedObject(OutputCFile, GCC::CFile, SharedObjectFile))
|
2003-10-15 05:09:11 +08:00
|
|
|
exit(1);
|
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-25 02:17:43 +08:00
|
|
|
|
|
|
|
// Remove the intermediate C file
|
|
|
|
removeFile(OutputCFile);
|
|
|
|
|
2003-10-15 05:09:11 +08:00
|
|
|
return SharedObjectFile;
|
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-25 02:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-24 07:50:16 +08:00
|
|
|
/// diffProgram - This method executes the specified module and diffs the output
|
|
|
|
/// against the file specified by ReferenceOutputFile. If the output is
|
|
|
|
/// different, true is returned.
|
|
|
|
///
|
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-25 02:17:43 +08:00
|
|
|
bool BugDriver::diffProgram(const std::string &BytecodeFile,
|
|
|
|
const std::string &SharedObject,
|
2003-04-25 01:02:17 +08:00
|
|
|
bool RemoveBytecode) {
|
2002-12-24 07:50:16 +08:00
|
|
|
// Execute the program, generating an output file...
|
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-25 02:17:43 +08:00
|
|
|
std::string Output = executeProgram("", BytecodeFile, SharedObject);
|
2002-12-24 07:50:16 +08:00
|
|
|
|
2003-08-02 04:29:45 +08:00
|
|
|
std::string Error;
|
2002-12-24 07:50:16 +08:00
|
|
|
bool FilesDifferent = false;
|
2003-08-02 04:29:45 +08:00
|
|
|
if (DiffFiles(ReferenceOutputFile, Output, &Error)) {
|
|
|
|
if (!Error.empty()) {
|
|
|
|
std::cerr << "While diffing output: " << Error << "\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FilesDifferent = true;
|
|
|
|
}
|
2003-10-19 05:02:51 +08:00
|
|
|
|
|
|
|
// Remove the generated output.
|
|
|
|
removeFile(Output);
|
2002-12-24 07:50:16 +08:00
|
|
|
|
2003-10-19 05:02:51 +08:00
|
|
|
// Remove the bytecode file if we are supposed to.
|
2003-04-25 01:02:17 +08:00
|
|
|
if (RemoveBytecode) removeFile(BytecodeFile);
|
2002-12-24 07:50:16 +08:00
|
|
|
return FilesDifferent;
|
|
|
|
}
|
2003-07-29 03:16:14 +08:00
|
|
|
|
|
|
|
bool BugDriver::isExecutingJIT() {
|
|
|
|
return InterpreterSel == RunJIT;
|
|
|
|
}
|