1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Add a stub for debugging code generator crashes

llvm-svn: 11602
This commit is contained in:
Chris Lattner 2004-02-18 21:02:04 +00:00
parent 5a22f3a7d1
commit 264e195392
4 changed files with 49 additions and 18 deletions

View File

@ -19,6 +19,7 @@
#include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Parser.h"
#include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Reader.h"
#include "llvm/Transforms/Utils/Linker.h" #include "llvm/Transforms/Utils/Linker.h"
#include "llvm/Support/ToolRunner.h"
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include "Support/FileUtilities.h" #include "Support/FileUtilities.h"
#include <memory> #include <memory>
@ -131,7 +132,7 @@ bool BugDriver::run() {
if (!PassesToRun.empty()) { if (!PassesToRun.empty()) {
std::cout << "Running selected passes on program to test for crash: "; std::cout << "Running selected passes on program to test for crash: ";
if (runPasses(PassesToRun)) if (runPasses(PassesToRun))
return debugCrash(); return debugOptimizerCrash();
} }
// Set up the execution environment, selecting a method to run LLVM bytecode. // Set up the execution environment, selecting a method to run LLVM bytecode.
@ -144,9 +145,20 @@ bool BugDriver::run() {
bool CreatedOutput = false; bool CreatedOutput = false;
if (ReferenceOutputFile.empty()) { if (ReferenceOutputFile.empty()) {
std::cout << "Generating reference output from raw program..."; std::cout << "Generating reference output from raw program...";
ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out"); try {
CreatedOutput = true; ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
std::cout << "Reference output is: " << ReferenceOutputFile << "\n"; 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 // 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 // Diff the output of the raw program against the reference output. If it
// matches, then we have a miscompilation bug. // matches, then we have a miscompilation bug.
std::cout << "*** Checking the code generator...\n"; std::cout << "*** Checking the code generator...\n";
if (!diffProgram()) { try {
std::cout << "\n*** Debugging miscompilation!\n"; if (!diffProgram()) {
return debugMiscompilation(); 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"; std::cout << "\n*** Input program does not match reference diff!\n";

View File

@ -75,11 +75,16 @@ public:
/// ///
bool run(); bool run();
/// debugCrash - This method is called when some pass crashes on input. It /// debugOptimizerCrash - This method is called when some optimizer pass
/// attempts to prune down the testcase to something reasonable, and figure /// crashes on input. It attempts to prune down the testcase to something
/// out exactly which pass is crashing. /// 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 /// debugMiscompilation - This method is used when the passes selected are not
/// crashing, but the generated output is semantically different from the /// crashing, but the generated output is semantically different from the

View File

@ -257,11 +257,11 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<BasicBlock*> &BBs) {
return false; return false;
} }
/// debugCrash - This method is called when some pass crashes on input. It /// debugOptimizerCrash - This method is called when some pass crashes on input.
/// attempts to prune down the testcase to something reasonable, and figure /// It attempts to prune down the testcase to something reasonable, and figure
/// out exactly which pass is crashing. /// out exactly which pass is crashing.
/// ///
bool BugDriver::debugCrash() { bool BugDriver::debugOptimizerCrash() {
bool AnyReduction = false; bool AnyReduction = false;
std::cout << "\n*** Debugging optimizer crash!\n"; std::cout << "\n*** Debugging optimizer crash!\n";
@ -408,3 +408,12 @@ bool BugDriver::debugCrash() {
return false; 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;
}

View File

@ -46,7 +46,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< " on the input program!\n"; << " on the input program!\n";
BD.setPassesToRun(Suffix); BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
exit(BD.debugCrash()); exit(BD.debugOptimizerCrash());
} }
// Check to see if the finished program matches the reference output... // 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"; << " on the input program!\n";
BD.setPassesToRun(Prefix); BD.setPassesToRun(Prefix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
exit(BD.debugCrash()); exit(BD.debugOptimizerCrash());
} }
// If the prefix maintains the predicate by itself, only keep the prefix! // 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"; << " on the input program!\n";
BD.setPassesToRun(Suffix); BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
exit(BD.debugCrash()); exit(BD.debugOptimizerCrash());
} }
// Run the result... // Run the result...
@ -225,7 +225,7 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
std::cerr << " Error running this sequence of passes" std::cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
exit(BD.debugCrash()); exit(BD.debugOptimizerCrash());
} }
if (!EmitBytecode) if (!EmitBytecode)