2002-11-21 06:28:10 +08:00
|
|
|
//===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===//
|
2005-04-22 08:00:37 +08:00
|
|
|
//
|
2003-10-21 01:47:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:44:31 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 08:00:37 +08:00
|
|
|
//
|
2003-10-21 01:47:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-11-21 06:28:10 +08:00
|
|
|
//
|
|
|
|
// This class contains all of the shared state and information that is used by
|
|
|
|
// the BugPoint tool to track down errors in optimizations. This class is the
|
|
|
|
// main driver class that invokes all sub-functionality.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "BugDriver.h"
|
2006-06-07 06:30:59 +08:00
|
|
|
#include "ToolRunner.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
2013-03-26 10:25:37 +08:00
|
|
|
#include "llvm/IRReader/IRReader.h"
|
2014-03-06 11:42:23 +08:00
|
|
|
#include "llvm/Linker/Linker.h"
|
2003-08-08 05:19:30 +08:00
|
|
|
#include "llvm/Pass.h"
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2012-12-04 18:44:52 +08:00
|
|
|
#include "llvm/Support/Host.h"
|
2009-07-03 06:46:18 +08:00
|
|
|
#include "llvm/Support/SourceMgr.h"
|
2009-01-02 15:01:27 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2002-11-21 06:28:10 +08:00
|
|
|
#include <memory>
|
2003-11-12 06:41:34 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-08-18 11:35:57 +08:00
|
|
|
namespace llvm {
|
|
|
|
Triple TargetTriple;
|
|
|
|
}
|
|
|
|
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
// Anonymous namespace to define command line options for 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.
|
|
|
|
//
|
2005-04-22 08:00:37 +08:00
|
|
|
cl::opt<std::string>
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
OutputFile("output", cl::desc("Specify a reference program output "
|
|
|
|
"(for miscompilation detection)"));
|
|
|
|
}
|
|
|
|
|
2004-02-19 05:24:48 +08:00
|
|
|
/// setNewProgram - If we reduce or update the program somehow, call this method
|
|
|
|
/// to update bugdriver with it. This deletes the old module and sets the
|
|
|
|
/// specified one as the current program.
|
|
|
|
void BugDriver::setNewProgram(Module *M) {
|
|
|
|
delete Program;
|
|
|
|
Program = M;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-25 01:02:17 +08:00
|
|
|
/// getPassesString - Turn a list of passes into a string which indicates the
|
|
|
|
/// command line options that must be passed to add the passes.
|
|
|
|
///
|
2010-08-08 11:55:08 +08:00
|
|
|
std::string llvm::getPassesString(const std::vector<std::string> &Passes) {
|
2003-04-25 01:02:17 +08:00
|
|
|
std::string Result;
|
|
|
|
for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
|
|
|
|
if (i) Result += " ";
|
|
|
|
Result += "-";
|
2010-08-08 11:55:08 +08:00
|
|
|
Result += Passes[i];
|
2003-04-25 01:02:17 +08:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-08-08 07:03:21 +08:00
|
|
|
BugDriver::BugDriver(const char *toolname, bool find_bugs,
|
2010-03-19 08:09:28 +08:00
|
|
|
unsigned timeout, unsigned memlimit, bool use_valgrind,
|
2009-07-02 07:13:44 +08:00
|
|
|
LLVMContext& ctxt)
|
2009-07-02 00:58:40 +08:00
|
|
|
: Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
|
2014-04-25 12:24:47 +08:00
|
|
|
Program(nullptr), Interpreter(nullptr), SafeInterpreter(nullptr),
|
|
|
|
gcc(nullptr), run_find_bugs(find_bugs), Timeout(timeout),
|
2010-03-19 08:09:28 +08:00
|
|
|
MemoryLimit(memlimit), UseValgrind(use_valgrind) {}
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
|
2010-03-22 13:23:37 +08:00
|
|
|
BugDriver::~BugDriver() {
|
|
|
|
delete Program;
|
2014-04-26 04:15:16 +08:00
|
|
|
if (Interpreter != SafeInterpreter)
|
|
|
|
delete Interpreter;
|
|
|
|
delete SafeInterpreter;
|
|
|
|
delete gcc;
|
2010-03-22 13:23:37 +08:00
|
|
|
}
|
|
|
|
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
|
2007-07-05 05:55:50 +08:00
|
|
|
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
|
2002-11-21 06:28:10 +08:00
|
|
|
/// return it, or return null if not possible.
|
|
|
|
///
|
2009-07-02 05:22:36 +08:00
|
|
|
Module *llvm::ParseInputFile(const std::string &Filename,
|
2009-07-02 07:13:44 +08:00
|
|
|
LLVMContext& Ctxt) {
|
2009-07-03 06:46:18 +08:00
|
|
|
SMDiagnostic Err;
|
2009-09-04 00:32:58 +08:00
|
|
|
Module *Result = ParseIRFile(Filename, Err, Ctxt);
|
|
|
|
if (!Result)
|
2011-10-16 12:47:35 +08:00
|
|
|
Err.print("bugpoint", errs());
|
2009-09-04 00:32:58 +08:00
|
|
|
|
2009-08-18 11:35:57 +08:00
|
|
|
// If we don't have an override triple, use the first one to configure
|
|
|
|
// bugpoint, or use the host triple if none provided.
|
|
|
|
if (Result) {
|
|
|
|
if (TargetTriple.getTriple().empty()) {
|
|
|
|
Triple TheTriple(Result->getTargetTriple());
|
|
|
|
|
|
|
|
if (TheTriple.getTriple().empty())
|
2011-11-02 05:32:20 +08:00
|
|
|
TheTriple.setTriple(sys::getDefaultTargetTriple());
|
2011-03-31 21:06:39 +08:00
|
|
|
|
2009-08-18 11:35:57 +08:00
|
|
|
TargetTriple.setTriple(TheTriple.getTriple());
|
|
|
|
}
|
|
|
|
|
|
|
|
Result->setTargetTriple(TargetTriple.getTriple()); // override the triple
|
|
|
|
}
|
2002-11-21 06:28:10 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method takes the specified list of LLVM input files, attempts to load
|
2007-07-05 05:55:50 +08:00
|
|
|
// them, either as assembly or bitcode, then link them together. It returns
|
|
|
|
// true on failure (if, for example, an input bitcode file could not be
|
2003-05-23 13:34:32 +08:00
|
|
|
// parsed), and false on success.
|
2002-11-21 06:28:10 +08:00
|
|
|
//
|
|
|
|
bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
|
2014-04-28 12:05:08 +08:00
|
|
|
assert(!Program && "Cannot call addSources multiple times!");
|
2002-11-21 06:28:10 +08:00
|
|
|
assert(!Filenames.empty() && "Must specify at least on input filename!");
|
|
|
|
|
2010-04-12 13:08:25 +08:00
|
|
|
// Load the first input file.
|
|
|
|
Program = ParseInputFile(Filenames[0], Context);
|
2014-04-25 12:24:47 +08:00
|
|
|
if (!Program) return true;
|
2011-03-31 21:06:39 +08:00
|
|
|
|
2010-08-08 07:03:21 +08:00
|
|
|
outs() << "Read input file : '" << Filenames[0] << "'\n";
|
2006-05-15 03:15:56 +08:00
|
|
|
|
2010-04-12 13:08:25 +08:00
|
|
|
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
|
2014-03-06 13:51:42 +08:00
|
|
|
std::unique_ptr<Module> M(ParseInputFile(Filenames[i], Context));
|
2014-04-25 12:24:47 +08:00
|
|
|
if (!M.get()) return true;
|
2006-05-15 03:15:56 +08:00
|
|
|
|
2010-08-08 07:03:21 +08:00
|
|
|
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
|
2010-04-12 13:08:25 +08:00
|
|
|
std::string ErrorMessage;
|
2011-10-11 08:24:54 +08:00
|
|
|
if (Linker::LinkModules(Program, M.get(), Linker::DestroySource,
|
|
|
|
&ErrorMessage)) {
|
2010-04-12 13:08:25 +08:00
|
|
|
errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
|
|
|
|
<< ErrorMessage << '\n';
|
|
|
|
return true;
|
2002-11-21 06:28:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-08 07:03:21 +08:00
|
|
|
outs() << "*** All input ok\n";
|
2002-11-21 06:28:10 +08:00
|
|
|
|
|
|
|
// All input files read successfully!
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// run - The top level method that is invoked after all of the instance
|
|
|
|
/// variables are set up from command line arguments.
|
|
|
|
///
|
2010-04-12 13:08:25 +08:00
|
|
|
bool BugDriver::run(std::string &ErrMsg) {
|
2006-08-16 00:40:49 +08:00
|
|
|
if (run_find_bugs) {
|
|
|
|
// Rearrange the passes and apply them to the program. Repeat this process
|
|
|
|
// until the user kills the program or we find a bug.
|
2010-04-12 13:08:25 +08:00
|
|
|
return runManyPasses(PassesToRun, ErrMsg);
|
2006-08-16 00:40:49 +08:00
|
|
|
}
|
2005-12-23 04:02:55 +08:00
|
|
|
|
2011-03-31 21:06:39 +08:00
|
|
|
// If we're not running as a child, the first thing that we must do is
|
|
|
|
// determine what the problem is. Does the optimization series crash the
|
|
|
|
// compiler, or does it produce illegal code? We make the top-level
|
2012-07-23 16:51:15 +08:00
|
|
|
// decision by trying to run all of the passes on the input program,
|
2011-03-31 21:06:39 +08:00
|
|
|
// which should generate a bitcode file. If it does generate a bitcode
|
|
|
|
// file, then we know the compiler didn't crash, so try to diagnose a
|
2005-12-23 04:02:55 +08:00
|
|
|
// miscompilation.
|
2003-10-14 05:04:26 +08:00
|
|
|
if (!PassesToRun.empty()) {
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "Running selected passes on program to test for crash: ";
|
2010-08-05 10:16:32 +08:00
|
|
|
if (runPasses(Program, PassesToRun))
|
2004-02-19 05:02:04 +08:00
|
|
|
return debugOptimizerCrash();
|
2003-10-14 05:04:26 +08:00
|
|
|
}
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
|
2007-07-05 05:55:50 +08:00
|
|
|
// Set up the execution environment, selecting a method to run LLVM bitcode.
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
if (initializeExecutionEnvironment()) return true;
|
|
|
|
|
2004-02-20 01:03:49 +08:00
|
|
|
// Test to see if we have a code generator crash.
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "Running the code generator to test for a crash: ";
|
2010-04-12 13:08:25 +08:00
|
|
|
std::string Error;
|
|
|
|
compileProgram(Program, &Error);
|
|
|
|
if (!Error.empty()) {
|
|
|
|
outs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-20 01:03:49 +08:00
|
|
|
}
|
2010-04-12 13:08:25 +08:00
|
|
|
outs() << '\n';
|
2004-02-20 01:03:49 +08:00
|
|
|
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
// 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 the code generator.
|
|
|
|
//
|
2003-08-23 02:57:43 +08:00
|
|
|
bool CreatedOutput = false;
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
if (ReferenceOutputFile.empty()) {
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "Generating reference output from raw program: ";
|
2010-04-12 13:08:25 +08:00
|
|
|
if (!createReferenceFile(Program)) {
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-19 05:02:04 +08:00
|
|
|
}
|
2006-08-16 00:40:49 +08:00
|
|
|
CreatedOutput = true;
|
2003-10-15 04:52:55 +08:00
|
|
|
}
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
|
2003-10-15 04:52:55 +08:00
|
|
|
// Make sure the reference output file gets deleted on exit from this
|
|
|
|
// function, if appropriate.
|
2013-06-19 00:21:54 +08:00
|
|
|
std::string ROF(ReferenceOutputFile);
|
|
|
|
FileRemover RemoverInstance(ROF, CreatedOutput && !SaveTemps);
|
2003-10-15 04:52:55 +08:00
|
|
|
|
|
|
|
// Diff the output of the raw program against the reference output. If it
|
2011-03-31 21:06:39 +08:00
|
|
|
// matches, then we assume there is a miscompilation bug and try to
|
2006-08-16 00:40:49 +08:00
|
|
|
// diagnose it.
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "*** Checking the code generator...\n";
|
2010-07-30 22:19:00 +08:00
|
|
|
bool Diff = diffProgram(Program, "", "", false, &Error);
|
2010-04-12 13:08:25 +08:00
|
|
|
if (!Error.empty()) {
|
|
|
|
errs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
|
|
|
}
|
|
|
|
if (!Diff) {
|
|
|
|
outs() << "\n*** Output matches: Debugging miscompilation!\n";
|
|
|
|
debugMiscompilation(&Error);
|
|
|
|
if (!Error.empty()) {
|
|
|
|
errs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-19 05:02:04 +08:00
|
|
|
}
|
2010-04-12 13:08:25 +08:00
|
|
|
return false;
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
}
|
|
|
|
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "\n*** Input program does not match reference diff!\n";
|
|
|
|
outs() << "Debugging code generator problem!\n";
|
2010-04-12 13:08:25 +08:00
|
|
|
bool Failure = debugCodeGenerator(&Error);
|
|
|
|
if (!Error.empty()) {
|
|
|
|
errs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-20 01:03:49 +08:00
|
|
|
}
|
2010-04-12 13:08:25 +08:00
|
|
|
return Failure;
|
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.
llvm-svn: 7293
2003-07-25 02:17:43 +08:00
|
|
|
}
|
|
|
|
|
2004-03-15 04:50:42 +08:00
|
|
|
void llvm::PrintFunctionList(const std::vector<Function*> &Funcs) {
|
|
|
|
unsigned NumPrint = Funcs.size();
|
|
|
|
if (NumPrint > 10) NumPrint = 10;
|
|
|
|
for (unsigned i = 0; i != NumPrint; ++i)
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << " " << Funcs[i]->getName();
|
2004-03-15 04:50:42 +08:00
|
|
|
if (NumPrint < Funcs.size())
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "... <" << Funcs.size() << " total>";
|
|
|
|
outs().flush();
|
2002-11-21 06:28:10 +08:00
|
|
|
}
|
2006-10-26 02:36:14 +08:00
|
|
|
|
|
|
|
void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs) {
|
|
|
|
unsigned NumPrint = GVs.size();
|
|
|
|
if (NumPrint > 10) NumPrint = 10;
|
|
|
|
for (unsigned i = 0; i != NumPrint; ++i)
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << " " << GVs[i]->getName();
|
2006-10-26 02:36:14 +08:00
|
|
|
if (NumPrint < GVs.size())
|
2009-07-16 23:30:09 +08:00
|
|
|
outs() << "... <" << GVs.size() << " total>";
|
|
|
|
outs().flush();
|
2006-10-26 02:36:14 +08:00
|
|
|
}
|