aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-18 21:02:04 +0000
committerChris Lattner <sabre@nondot.org>2004-02-18 21:02:04 +0000
commit025262692a6710de29a48e2b3905672cd12d13d2 (patch)
tree1730e50e0aa5132a62f15c28d86918b2ff5e087d /tools
parenta3de11783f04a53ffb625a7ced7d6080705c9762 (diff)
downloadexternal_llvm-025262692a6710de29a48e2b3905672cd12d13d2.zip
external_llvm-025262692a6710de29a48e2b3905672cd12d13d2.tar.gz
external_llvm-025262692a6710de29a48e2b3905672cd12d13d2.tar.bz2
Add a stub for debugging code generator crashes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/BugDriver.cpp31
-rw-r--r--tools/bugpoint/BugDriver.h13
-rw-r--r--tools/bugpoint/CrashDebugger.cpp15
-rw-r--r--tools/bugpoint/Miscompilation.cpp8
4 files changed, 49 insertions, 18 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 08f2bb5..14e5606 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -19,6 +19,7 @@
#include "llvm/Assembly/Parser.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Transforms/Utils/Linker.h"
+#include "llvm/Support/ToolRunner.h"
#include "Support/CommandLine.h"
#include "Support/FileUtilities.h"
#include <memory>
@@ -131,7 +132,7 @@ bool BugDriver::run() {
if (!PassesToRun.empty()) {
std::cout << "Running selected passes on program to test for crash: ";
if (runPasses(PassesToRun))
- return debugCrash();
+ return debugOptimizerCrash();
}
// Set up the execution environment, selecting a method to run LLVM bytecode.
@@ -144,9 +145,20 @@ bool BugDriver::run() {
bool CreatedOutput = false;
if (ReferenceOutputFile.empty()) {
std::cout << "Generating reference output from raw program...";
- ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
- CreatedOutput = true;
- std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
+ try {
+ ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
+ CreatedOutput = true;
+ std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
+ } catch (ToolExecutionError &TEE) {
+ std::cerr << TEE.getMessage();
+ 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 1;
+ }
+ return debugCodeGeneratorCrash();
+ }
}
// Make sure the reference output file gets deleted on exit from this
@@ -156,9 +168,14 @@ bool BugDriver::run() {
// Diff the output of the raw program against the reference output. If it
// matches, then we have a miscompilation bug.
std::cout << "*** Checking the code generator...\n";
- if (!diffProgram()) {
- std::cout << "\n*** Debugging miscompilation!\n";
- return debugMiscompilation();
+ try {
+ if (!diffProgram()) {
+ std::cout << "\n*** Debugging miscompilation!\n";
+ return debugMiscompilation();
+ }
+ } catch (ToolExecutionError &TEE) {
+ std::cerr << TEE.getMessage() << "*** Debugging code generator crash!\n";
+ return debugCodeGeneratorCrash();
}
std::cout << "\n*** Input program does not match reference diff!\n";
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index 2dd4f37..4d6754a 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -75,11 +75,16 @@ public:
///
bool run();
- /// debugCrash - This method is called when some pass crashes on input. It
- /// attempts to prune down the testcase to something reasonable, and figure
- /// out exactly which pass is crashing.
+ /// debugOptimizerCrash - This method is called when some optimizer pass
+ /// crashes on input. It attempts to prune down the testcase to something
+ /// reasonable, and figure out exactly which pass is crashing.
///
- bool debugCrash();
+ bool debugOptimizerCrash();
+
+ /// debugCodeGeneratorCrash - This method is called when the code generator
+ /// crashes on an input. It attempts to reduce the input as much as possible
+ /// while still causing the code generator to crash.
+ bool debugCodeGeneratorCrash();
/// debugMiscompilation - This method is used when the passes selected are not
/// crashing, but the generated output is semantically different from the
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index ecb1734..92b8f7c 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -257,11 +257,11 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<BasicBlock*> &BBs) {
return false;
}
-/// debugCrash - This method is called when some pass crashes on input. It
-/// attempts to prune down the testcase to something reasonable, and figure
+/// debugOptimizerCrash - This method is called when some pass crashes on input.
+/// It attempts to prune down the testcase to something reasonable, and figure
/// out exactly which pass is crashing.
///
-bool BugDriver::debugCrash() {
+bool BugDriver::debugOptimizerCrash() {
bool AnyReduction = false;
std::cout << "\n*** Debugging optimizer crash!\n";
@@ -408,3 +408,12 @@ bool BugDriver::debugCrash() {
return false;
}
+
+
+/// debugCodeGeneratorCrash - This method is called when the code generator
+/// crashes on an input. It attempts to reduce the input as much as possible
+/// while still causing the code generator to crash.
+bool BugDriver::debugCodeGeneratorCrash() {
+
+ return false;
+}
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 7158608..0884ad9 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -46,7 +46,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false);
- exit(BD.debugCrash());
+ exit(BD.debugOptimizerCrash());
}
// Check to see if the finished program matches the reference output...
@@ -74,7 +74,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< " on the input program!\n";
BD.setPassesToRun(Prefix);
BD.EmitProgressBytecode("pass-error", false);
- exit(BD.debugCrash());
+ exit(BD.debugOptimizerCrash());
}
// If the prefix maintains the predicate by itself, only keep the prefix!
@@ -107,7 +107,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false);
- exit(BD.debugCrash());
+ exit(BD.debugOptimizerCrash());
}
// Run the result...
@@ -225,7 +225,7 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
std::cerr << " Error running this sequence of passes"
<< " on the input program!\n";
BD.EmitProgressBytecode("pass-error", false);
- exit(BD.debugCrash());
+ exit(BD.debugOptimizerCrash());
}
if (!EmitBytecode)