2002-11-20 22:28:10 +00:00
|
|
|
//===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===//
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2003-10-20 17:47:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:44:31 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2003-10-20 17:47:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-11-20 22:28:10 +00: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-06 22:30:59 +00:00
|
|
|
#include "ToolRunner.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
2013-03-26 02:25:37 +00:00
|
|
|
#include "llvm/IRReader/IRReader.h"
|
2004-11-14 23:00:08 +00:00
|
|
|
#include "llvm/Linker.h"
|
2003-08-07 21:19:30 +00:00
|
|
|
#include "llvm/Pass.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2012-12-04 10:44:52 +00:00
|
|
|
#include "llvm/Support/Host.h"
|
2009-07-02 22:46:18 +00:00
|
|
|
#include "llvm/Support/SourceMgr.h"
|
2009-01-02 07:01:27 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2002-11-20 22:28:10 +00:00
|
|
|
#include <memory>
|
2003-11-11 22:41:34 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-08-18 03:35:57 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00: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 00:00:37 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
OutputFile("output", cl::desc("Specify a reference program output "
|
|
|
|
"(for miscompilation detection)"));
|
|
|
|
}
|
|
|
|
|
2004-02-18 21:24:48 +00: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-24 17:02:17 +00: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 03:55:08 +00:00
|
|
|
std::string llvm::getPassesString(const std::vector<std::string> &Passes) {
|
2003-04-24 17:02:17 +00:00
|
|
|
std::string Result;
|
|
|
|
for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
|
|
|
|
if (i) Result += " ";
|
|
|
|
Result += "-";
|
2010-08-08 03:55:08 +00:00
|
|
|
Result += Passes[i];
|
2003-04-24 17:02:17 +00:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-08-07 23:03:21 +00:00
|
|
|
BugDriver::BugDriver(const char *toolname, bool find_bugs,
|
2010-03-19 00:09:28 +00:00
|
|
|
unsigned timeout, unsigned memlimit, bool use_valgrind,
|
2009-07-01 23:13:44 +00:00
|
|
|
LLVMContext& ctxt)
|
2009-07-01 16:58:40 +00:00
|
|
|
: Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
|
2008-12-08 04:02:47 +00:00
|
|
|
Program(0), Interpreter(0), SafeInterpreter(0), gcc(0),
|
2011-03-31 13:06:39 +00:00
|
|
|
run_find_bugs(find_bugs), Timeout(timeout),
|
2010-03-19 00:09:28 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
2010-03-22 05:23:37 +00:00
|
|
|
BugDriver::~BugDriver() {
|
|
|
|
delete Program;
|
|
|
|
}
|
|
|
|
|
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
2003-07-24 18:17:43 +00:00
|
|
|
|
2007-07-04 21:55:50 +00:00
|
|
|
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
|
2002-11-20 22:28:10 +00:00
|
|
|
/// return it, or return null if not possible.
|
|
|
|
///
|
2009-07-01 21:22:36 +00:00
|
|
|
Module *llvm::ParseInputFile(const std::string &Filename,
|
2009-07-01 23:13:44 +00:00
|
|
|
LLVMContext& Ctxt) {
|
2009-07-02 22:46:18 +00:00
|
|
|
SMDiagnostic Err;
|
2009-09-03 16:32:58 +00:00
|
|
|
Module *Result = ParseIRFile(Filename, Err, Ctxt);
|
|
|
|
if (!Result)
|
2011-10-16 04:47:35 +00:00
|
|
|
Err.print("bugpoint", errs());
|
2009-09-03 16:32:58 +00:00
|
|
|
|
2009-08-18 03:35:57 +00: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-01 21:32:20 +00:00
|
|
|
TheTriple.setTriple(sys::getDefaultTargetTriple());
|
2011-03-31 13:06:39 +00:00
|
|
|
|
2009-08-18 03:35:57 +00:00
|
|
|
TargetTriple.setTriple(TheTriple.getTriple());
|
|
|
|
}
|
|
|
|
|
|
|
|
Result->setTargetTriple(TargetTriple.getTriple()); // override the triple
|
|
|
|
}
|
2002-11-20 22:28:10 +00:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method takes the specified list of LLVM input files, attempts to load
|
2007-07-04 21:55:50 +00: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 05:34:32 +00:00
|
|
|
// parsed), and false on success.
|
2002-11-20 22:28:10 +00:00
|
|
|
//
|
|
|
|
bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
|
|
|
|
assert(Program == 0 && "Cannot call addSources multiple times!");
|
|
|
|
assert(!Filenames.empty() && "Must specify at least on input filename!");
|
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
// Load the first input file.
|
|
|
|
Program = ParseInputFile(Filenames[0], Context);
|
|
|
|
if (Program == 0) return true;
|
2011-03-31 13:06:39 +00:00
|
|
|
|
2010-08-07 23:03:21 +00:00
|
|
|
outs() << "Read input file : '" << Filenames[0] << "'\n";
|
2006-05-14 19:15:56 +00:00
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
|
2013-04-12 10:56:28 +00:00
|
|
|
OwningPtr<Module> M(ParseInputFile(Filenames[i], Context));
|
2010-04-12 05:08:25 +00:00
|
|
|
if (M.get() == 0) return true;
|
2006-05-14 19:15:56 +00:00
|
|
|
|
2010-08-07 23:03:21 +00:00
|
|
|
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string ErrorMessage;
|
2011-10-11 00:24:54 +00:00
|
|
|
if (Linker::LinkModules(Program, M.get(), Linker::DestroySource,
|
|
|
|
&ErrorMessage)) {
|
2010-04-12 05:08:25 +00:00
|
|
|
errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
|
|
|
|
<< ErrorMessage << '\n';
|
|
|
|
return true;
|
2002-11-20 22:28:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-07 23:03:21 +00:00
|
|
|
outs() << "*** All input ok\n";
|
2002-11-20 22:28:10 +00: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 05:08:25 +00:00
|
|
|
bool BugDriver::run(std::string &ErrMsg) {
|
2006-08-15 16:40:49 +00: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 05:08:25 +00:00
|
|
|
return runManyPasses(PassesToRun, ErrMsg);
|
2006-08-15 16:40:49 +00:00
|
|
|
}
|
2005-12-22 20:02:55 +00:00
|
|
|
|
2011-03-31 13:06:39 +00: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 08:51:15 +00:00
|
|
|
// decision by trying to run all of the passes on the input program,
|
2011-03-31 13:06:39 +00: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-22 20:02:55 +00:00
|
|
|
// miscompilation.
|
2003-10-13 21:04:26 +00:00
|
|
|
if (!PassesToRun.empty()) {
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "Running selected passes on program to test for crash: ";
|
2010-08-05 02:16:32 +00:00
|
|
|
if (runPasses(Program, PassesToRun))
|
2004-02-18 21:02:04 +00:00
|
|
|
return debugOptimizerCrash();
|
2003-10-13 21:04:26 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
2007-07-04 21:55:50 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
if (initializeExecutionEnvironment()) return true;
|
|
|
|
|
2004-02-19 17:03:49 +00:00
|
|
|
// Test to see if we have a code generator crash.
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "Running the code generator to test for a crash: ";
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string Error;
|
|
|
|
compileProgram(Program, &Error);
|
|
|
|
if (!Error.empty()) {
|
|
|
|
outs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-19 17:03:49 +00:00
|
|
|
}
|
2010-04-12 05:08:25 +00:00
|
|
|
outs() << '\n';
|
2004-02-19 17:03:49 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00: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-22 18:57:43 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
if (ReferenceOutputFile.empty()) {
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "Generating reference output from raw program: ";
|
2010-04-12 05:08:25 +00:00
|
|
|
if (!createReferenceFile(Program)) {
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-18 21:02:04 +00:00
|
|
|
}
|
2006-08-15 16:40:49 +00:00
|
|
|
CreatedOutput = true;
|
2003-10-14 20:52:55 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
2003-10-14 20:52:55 +00:00
|
|
|
// Make sure the reference output file gets deleted on exit from this
|
|
|
|
// function, if appropriate.
|
2013-06-18 16:21:54 +00:00
|
|
|
std::string ROF(ReferenceOutputFile);
|
|
|
|
FileRemover RemoverInstance(ROF, CreatedOutput && !SaveTemps);
|
2003-10-14 20:52:55 +00:00
|
|
|
|
|
|
|
// Diff the output of the raw program against the reference output. If it
|
2011-03-31 13:06:39 +00:00
|
|
|
// matches, then we assume there is a miscompilation bug and try to
|
2006-08-15 16:40:49 +00:00
|
|
|
// diagnose it.
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "*** Checking the code generator...\n";
|
2010-07-30 14:19:00 +00:00
|
|
|
bool Diff = diffProgram(Program, "", "", false, &Error);
|
2010-04-12 05:08:25 +00: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-18 21:02:04 +00:00
|
|
|
}
|
2010-04-12 05:08:25 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "\n*** Input program does not match reference diff!\n";
|
|
|
|
outs() << "Debugging code generator problem!\n";
|
2010-04-12 05:08:25 +00:00
|
|
|
bool Failure = debugCodeGenerator(&Error);
|
|
|
|
if (!Error.empty()) {
|
|
|
|
errs() << Error;
|
|
|
|
return debugCodeGeneratorCrash(ErrMsg);
|
2004-02-19 17:03:49 +00:00
|
|
|
}
|
2010-04-12 05:08:25 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 20:50:42 +00: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 15:30:09 +00:00
|
|
|
outs() << " " << Funcs[i]->getName();
|
2004-03-14 20:50:42 +00:00
|
|
|
if (NumPrint < Funcs.size())
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "... <" << Funcs.size() << " total>";
|
|
|
|
outs().flush();
|
2002-11-20 22:28:10 +00:00
|
|
|
}
|
2006-10-25 18:36:14 +00: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 15:30:09 +00:00
|
|
|
outs() << " " << GVs[i]->getName();
|
2006-10-25 18:36:14 +00:00
|
|
|
if (NumPrint < GVs.size())
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "... <" << GVs.size() << " total>";
|
|
|
|
outs().flush();
|
2006-10-25 18:36:14 +00:00
|
|
|
}
|