aboutsummaryrefslogtreecommitdiff
path: root/tools/bugpoint/Miscompilation.cpp
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-07-24 18:17:43 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-07-24 18:17:43 +0000
commit5073336cd4da5df4ae13a167582d1dc90f32e4e0 (patch)
tree1d91677c5c7dbdbad402706b99ce7fe10f0637c2 /tools/bugpoint/Miscompilation.cpp
parent08fd7abb42cadf2d14a3ca8103b73a358468391f (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/Miscompilation.cpp')
-rw-r--r--tools/bugpoint/Miscompilation.cpp55
1 files changed, 8 insertions, 47 deletions
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 333eb13244..833dd437b6 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -11,21 +11,6 @@
#include "llvm/Module.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Linker.h"
-#include "Support/CommandLine.h"
-
-// Anonymous namespace to define command line options for miscompilation
-// debugging.
-//
-namespace {
- // Output - The user can specify a file containing the expected output of the
- // program. If this filename is set, it is used as the reference diff source,
- // otherwise the raw input run through an interpreter is used as the reference
- // source.
- //
- cl::opt<std::string>
- Output("output", cl::desc("Specify a reference program output "
- "(for miscompilation detection)"));
-}
class ReduceMiscompilingPasses : public ListReducer<const PassInfo*> {
BugDriver &BD;
@@ -33,7 +18,7 @@ public:
ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
virtual TestResult doTest(std::vector<const PassInfo*> &Prefix,
- std::vector<const PassInfo*> &Kept);
+ std::vector<const PassInfo*> &Suffix);
};
ReduceMiscompilingPasses::TestResult
@@ -52,7 +37,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
}
// Check to see if the finished program matches the reference output...
- if (BD.diffProgram(Output, BytecodeResult, true /*delete bytecode*/)) {
+ if (BD.diffProgram(BytecodeResult, "", true /*delete bytecode*/)) {
std::cout << "nope.\n";
return KeepSuffix; // Miscompilation detected!
}
@@ -78,7 +63,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
}
// If the prefix maintains the predicate by itself, only keep the prefix!
- if (BD.diffProgram(Output, BytecodeResult)) {
+ if (BD.diffProgram(BytecodeResult)) {
std::cout << "nope.\n";
removeFile(BytecodeResult);
return KeepPrefix;
@@ -109,7 +94,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
}
// Run the result...
- if (BD.diffProgram(Output, BytecodeResult, true/*delete bytecode*/)) {
+ if (BD.diffProgram(BytecodeResult, "", true/*delete bytecode*/)) {
std::cout << "nope.\n";
delete OriginalInput; // We pruned down the original input...
return KeepSuffix;
@@ -122,14 +107,6 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
return NoFailure;
}
-static void PrintFunctionList(const std::vector<Function*> &Funcs) {
- for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
- if (i) std::cout << ", ";
- std::cout << Funcs[i]->getName();
- }
-}
-
-
class ReduceMiscompilingFunctions : public ListReducer<Function*> {
BugDriver &BD;
public:
@@ -154,7 +131,7 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
if (!EmitBytecode) {
std::cout << "Checking to see if the program is misoptimized when these "
<< "functions are run\nthrough the passes: ";
- PrintFunctionList(Funcs);
+ BD.PrintFunctionList(Funcs);
std::cout << "\n";
} else {
std::cout <<"Outputting reduced bytecode files which expose the problem:\n";
@@ -269,7 +246,7 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
// Eighth step: Execute the program. If it does not match the expected
// output, then 'Funcs' are being misoptimized!
- bool Broken = BD.diffProgram(Output);
+ bool Broken = BD.diffProgram();
delete BD.Program; // Delete the hacked up program
BD.Program = OldProgram; // Restore the original
@@ -284,24 +261,10 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
/// input.
///
bool BugDriver::debugMiscompilation() {
- std::cout << "*** Debugging miscompilation!\n";
- // Set up the execution environment, selecting a method to run LLVM bytecode.
- if (initializeExecutionEnvironment()) return true;
-
- // Run the raw input to see where we are coming from. If a reference output
- // was specified, make sure that the raw output matches it. If not, it's a
- // problem in the front-end or whatever produced the input code.
- //
- bool CreatedOutput = false;
- if (Output.empty()) {
- std::cout << "Generating reference output from raw program...";
- Output = executeProgram("bugpoint.reference.out");
- CreatedOutput = true;
- std::cout << " done! Reference output is: " << Output << "\n";
- } else if (diffProgram(Output)) {
+ if (diffProgram()) {
std::cout << "\n*** Input program does not match reference diff!\n"
- << " Must be problem with input source!\n";
+ << " Must be problem with input source!\n";
return false; // Problem found
}
@@ -321,7 +284,6 @@ bool BugDriver::debugMiscompilation() {
<< getPassesString(PassesToRun) << "\n";
EmitProgressBytecode("passinput");
-
// Okay, now that we have reduced the list of passes which are causing the
// failure, see if we can pin down which functions are being
// miscompiled... first build a list of all of the non-external functions in
@@ -341,6 +303,5 @@ bool BugDriver::debugMiscompilation() {
// Output a bunch of bytecode files for the user...
ReduceMiscompilingFunctions(*this).TestFuncs(MiscompiledFunctions, true);
- if (CreatedOutput) removeFile(Output);
return false;
}