aboutsummaryrefslogtreecommitdiff
path: root/tools/bugpoint/ExecutionDriver.cpp
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-07-28 19:16:14 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-07-28 19:16:14 +0000
commit91eabc13d3a456cc4b387d3d7fdb041d976732c7 (patch)
tree37bbf006f43e2c10ef859c2d2d7b3204ee5df0ac /tools/bugpoint/ExecutionDriver.cpp
parentd69c1e6dc28bed3c156f78fee5253748e3d509e2 (diff)
BugDriver.h:
* Added method to query if BugDriver is executing the JIT currently. This provides the ability in adding code that is conditionally executed in codegen debugging phase. CodeGeneratorBug.cpp: * Delete test functions from the Safe module * Code conditionally added when debugging the JIT: use the lazy resolver function added to Emitter.cpp to get function pointer by name. When compiled into an .so, this is the only way to get a pointer to an external function * Added a symbol disambiguator which will keep symbols uniquely named across modules * Delete generated files by default * The function `main' *must* stay in the .bc file for the JIT, but that prevents debugging it alone. This patch makes the old `main' become `old_main' and adds a new function named `main' which just calls the original with the same parameters, thereby keeping functionality the same. ExecutionDriver.cpp: * Returned to getting unique filenames * Simplified code choosing between using and not using shared library option git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7364 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/ExecutionDriver.cpp')
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index b391b0492f..adca572075 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -17,6 +17,7 @@ BUGPOINT NOTES:
#include "BugDriver.h"
#include "SystemUtils.h"
#include "Support/CommandLine.h"
+#include "Support/Statistic.h"
#include <fstream>
#include <iostream>
@@ -101,12 +102,13 @@ int LLI::ExecuteProgram(const std::string &Bytecode,
0
};
+ std::cout << "<lli>";
return RunProgramWithTimeout(LLIPath, Args,
InputFile, OutputFile, OutputFile);
}
//===----------------------------------------------------------------------===//
-// GCC Implementation of AbstractIntepreter interface
+// GCC abstraction
//
// This is not a *real* AbstractInterpreter as it does not accept bytecode
// files, but only input acceptable to GCC, i.e. C, C++, and assembly files
@@ -145,7 +147,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
FileType fileType,
const std::string &OutputFile,
const std::string &SharedLib) {
- std::string OutputBinary = "bugpoint.gcc.exe";
+ std::string OutputBinary = getUniqueFilename("bugpoint.gcc.exe");
const char **GCCArgs;
const char *ArgsWithoutSO[] = {
@@ -159,9 +161,9 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
};
const char *ArgsWithSO[] = {
GCCPath.c_str(),
+ SharedLib.c_str(), // Specify the shared library to link in...
"-x", (fileType == AsmFile) ? "assembler" : "c",
ProgramFile.c_str(), // Specify the input filename...
- SharedLib.c_str(), // Specify the shared library to link in...
"-o", OutputBinary.c_str(), // Output to the right filename...
"-lm", // Hard-code the math library...
"-O2", // Optimize the program a bit...
@@ -181,9 +183,8 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
0
};
- std::cout << "<program>";
-
// Now that we have a binary, run it!
+ std::cout << "<program>";
int ProgramResult = RunProgramWithTimeout(OutputBinary, ProgramArgs,
InputFile, OutputFile, OutputFile);
std::cout << "\n";
@@ -194,7 +195,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
int GCC::MakeSharedObject(const std::string &InputFile,
FileType fileType,
std::string &OutputFile) {
- OutputFile = "./bugpoint.so";
+ OutputFile = getUniqueFilename("./bugpoint.so");
// Compile the C/asm file into a shared object
const char* GCCArgs[] = {
GCCPath.c_str(),
@@ -277,7 +278,6 @@ public:
int OutputAsm(const std::string &Bytecode,
std::string &OutputAsmFile);
-
};
int LLC::OutputAsm(const std::string &Bytecode,
@@ -347,26 +347,25 @@ public:
int JIT::ExecuteProgram(const std::string &Bytecode,
const std::string &OutputFile,
const std::string &SharedLib) {
- if (SharedLib.empty()) {
- const char* Args[] = {
- LLIPath.c_str(),
- "-quiet",
- "-force-interpreter=false",
- Bytecode.c_str(),
- 0
- };
- return RunProgramWithTimeout(LLIPath, Args,
- InputFile, OutputFile, OutputFile);
- } else {
- const char* Args[] = {
- LLIPath.c_str(), "-quiet", "-force-interpreter=false",
- "-load", SharedLib.c_str(),
- Bytecode.c_str(),
- 0
- };
- return RunProgramWithTimeout(LLIPath, Args,
- InputFile, OutputFile, OutputFile);
- }
+ const char* ArgsWithoutSO[] = {
+ LLIPath.c_str(), "-quiet", "-force-interpreter=false",
+ Bytecode.c_str(),
+ 0
+ };
+
+ const char* ArgsWithSO[] = {
+ LLIPath.c_str(), "-quiet", "-force-interpreter=false",
+ "-load", SharedLib.c_str(),
+ Bytecode.c_str(),
+ 0
+ };
+
+ const char** JITArgs = SharedLib.empty() ? ArgsWithoutSO : ArgsWithSO;
+
+ std::cout << "<jit>";
+ DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
+ return RunProgramWithTimeout(LLIPath, JITArgs,
+ InputFile, OutputFile, OutputFile);
}
//===----------------------------------------------------------------------===//
@@ -591,7 +590,11 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
if (C1 != C2) { FilesDifferent = true; break; }
} while (C1 != EOF);
- removeFile(Output);
+ //removeFile(Output);
if (RemoveBytecode) removeFile(BytecodeFile);
return FilesDifferent;
}
+
+bool BugDriver::isExecutingJIT() {
+ return InterpreterSel == RunJIT;
+}