summaryrefslogtreecommitdiff
path: root/tools/bugpoint/ExecutionDriver.cpp
diff options
context:
space:
mode:
authorPatrick Jenkins <pjenkins@apple.com>2006-08-15 16:40:49 +0000
committerPatrick Jenkins <pjenkins@apple.com>2006-08-15 16:40:49 +0000
commit6a3f31cb707972ebde1e45a61fa8f5bcff132eba (patch)
tree4d27d945a930f13d72bd80f3a45b8fd3acf7cf11 /tools/bugpoint/ExecutionDriver.cpp
parent19af0e1b499b3e9d27b8865aa0634f771591cb43 (diff)
downloadllvm-6a3f31cb707972ebde1e45a61fa8f5bcff132eba.tar.gz
llvm-6a3f31cb707972ebde1e45a61fa8f5bcff132eba.tar.bz2
llvm-6a3f31cb707972ebde1e45a61fa8f5bcff132eba.tar.xz
This commit adds a new feature called find-bugs. The find-bugs option can be invoked on a .bc file from the command like with -find-bugs and a list of passes you wish to test. This procedure takes the set of optimization passes the user specifies, randomizes the passes, runs the passes on the specified .bc file, compiles the program, and finally runs the program checking its output vs the .bc file with no optimizations. This process repeats until either the user kills bugpoint or an error occurs in the optimizations, program complitation, or the running of the program. If an error occurs, bugpoint attempts to diagnose the error by eliminating passes that are not at fault and code that is not needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/ExecutionDriver.cpp')
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index 453833eb8d..93eef5dbc5 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -297,10 +297,36 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
return "./" + SharedObjectFile;
}
+/// createReferenceFile - calls compileProgram and then records the output
+/// into ReferenceOutputFile. Returns true if reference file created, false
+/// otherwise. Note: initializeExecutionEnvironment should be called BEFORE
+/// this function.
+///
+bool BugDriver::createReferenceFile(Module *M, const std::string &Filename){
+ try {
+ compileProgram(Program);
+ } catch (ToolExecutionError &TEE) {
+ return false;
+ }
+ try {
+ ReferenceOutputFile = executeProgramWithCBE(Filename);
+ std::cout << "Reference output is: " << ReferenceOutputFile << "\n\n";
+ } catch (ToolExecutionError &TEE) {
+ std::cerr << TEE.what();
+ if (Interpreter != cbe) {
+ std::cerr << "*** There is a bug running the C backend. Either debug"
+ << " it (use the -run-cbe bugpoint option), or fix the error"
+ << " some other way.\n";
+ }
+ return false;
+ }
+ return true;
+}
-/// 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.
+/// 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. If there is a problem with the code
+/// generator (e.g., llc crashes), this will throw an exception.
///
bool BugDriver::diffProgram(const std::string &BytecodeFile,
const std::string &SharedObject,