2002-12-23 23:50:16 +00:00
|
|
|
//===- ExecutionDriver.cpp - Allow execution of LLVM program --------------===//
|
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-12-23 23:50:16 +00:00
|
|
|
//
|
|
|
|
// This file contains code used to execute the program utilizing one of the
|
2007-07-04 21:55:50 +00:00
|
|
|
// various ways of running LLVM bitcode.
|
2002-12-23 23:50:16 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "BugDriver.h"
|
2006-06-06 22:30:59 +00:00
|
|
|
#include "ToolRunner.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/FileUtilities.h"
|
|
|
|
#include "llvm/Support/SystemUtils.h"
|
2009-08-23 22:45:37 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2002-12-23 23:50:16 +00:00
|
|
|
#include <fstream>
|
2006-06-06 00:00:42 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
namespace {
|
|
|
|
// OutputType - Allow the user to specify the way code should be run, to test
|
|
|
|
// for miscompilation.
|
|
|
|
//
|
|
|
|
enum OutputType {
|
2011-02-08 18:20:48 +00:00
|
|
|
AutoPick, RunLLI, RunJIT, RunLLC, RunLLCIA, RunCBE, CBE_bug, LLC_Safe,
|
|
|
|
CompileCustom, Custom
|
2002-12-23 23:50:16 +00:00
|
|
|
};
|
2003-09-29 22:40:52 +00:00
|
|
|
|
2005-01-23 03:45:26 +00:00
|
|
|
cl::opt<double>
|
|
|
|
AbsTolerance("abs-tolerance", cl::desc("Absolute error tolerated"),
|
|
|
|
cl::init(0.0));
|
|
|
|
cl::opt<double>
|
|
|
|
RelTolerance("rel-tolerance", cl::desc("Relative error tolerated"),
|
|
|
|
cl::init(0.0));
|
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
cl::opt<OutputType>
|
2008-12-08 04:02:47 +00:00
|
|
|
InterpreterSel(cl::desc("Specify the \"test\" i.e. suspect back-end:"),
|
2003-10-21 17:41:35 +00:00
|
|
|
cl::values(clEnumValN(AutoPick, "auto", "Use best guess"),
|
2004-04-19 03:12:35 +00:00
|
|
|
clEnumValN(RunLLI, "run-int",
|
|
|
|
"Execute with the interpreter"),
|
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
|
|
|
clEnumValN(RunJIT, "run-jit", "Execute with JIT"),
|
|
|
|
clEnumValN(RunLLC, "run-llc", "Compile with LLC"),
|
2010-03-16 06:41:47 +00:00
|
|
|
clEnumValN(RunLLCIA, "run-llc-ia",
|
|
|
|
"Compile with LLC with integrated assembler"),
|
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
|
|
|
clEnumValN(RunCBE, "run-cbe", "Compile with CBE"),
|
2006-09-15 21:29:15 +00:00
|
|
|
clEnumValN(CBE_bug,"cbe-bug", "Find CBE bugs"),
|
2006-11-09 05:57:53 +00:00
|
|
|
clEnumValN(LLC_Safe, "llc-safe", "Use LLC for all"),
|
2011-02-08 18:20:48 +00:00
|
|
|
clEnumValN(CompileCustom, "compile-custom",
|
|
|
|
"Use -compile-command to define a command to "
|
|
|
|
"compile the bitcode. Useful to avoid linking."),
|
2008-04-28 20:53:48 +00:00
|
|
|
clEnumValN(Custom, "run-custom",
|
|
|
|
"Use -exec-command to define a command to execute "
|
|
|
|
"the bitcode. Useful for cross-compilation."),
|
2004-07-16 00:08:28 +00:00
|
|
|
clEnumValEnd),
|
2003-10-21 17:41:35 +00:00
|
|
|
cl::init(AutoPick));
|
2003-04-23 20:31:37 +00:00
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
cl::opt<OutputType>
|
|
|
|
SafeInterpreterSel(cl::desc("Specify \"safe\" i.e. known-good backend:"),
|
2009-07-21 19:25:09 +00:00
|
|
|
cl::values(clEnumValN(AutoPick, "safe-auto", "Use best guess"),
|
|
|
|
clEnumValN(RunLLC, "safe-run-llc", "Compile with LLC"),
|
|
|
|
clEnumValN(RunCBE, "safe-run-cbe", "Compile with CBE"),
|
|
|
|
clEnumValN(Custom, "safe-run-custom",
|
|
|
|
"Use -exec-command to define a command to execute "
|
|
|
|
"the bitcode. Useful for cross-compilation."),
|
|
|
|
clEnumValEnd),
|
2008-12-08 04:02:47 +00:00
|
|
|
cl::init(AutoPick));
|
|
|
|
|
|
|
|
cl::opt<std::string>
|
|
|
|
SafeInterpreterPath("safe-path",
|
2009-07-21 19:25:09 +00:00
|
|
|
cl::desc("Specify the path to the \"safe\" backend program"),
|
|
|
|
cl::init(""));
|
2008-12-08 04:02:47 +00:00
|
|
|
|
2006-11-28 07:04:10 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
AppendProgramExitCode("append-exit-code",
|
|
|
|
cl::desc("Append the exit code to the output so it gets diff'd too"),
|
|
|
|
cl::init(false));
|
|
|
|
|
2003-04-23 20:31:37 +00:00
|
|
|
cl::opt<std::string>
|
|
|
|
InputFile("input", cl::init("/dev/null"),
|
|
|
|
cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
|
2003-10-14 22:24:31 +00:00
|
|
|
|
|
|
|
cl::list<std::string>
|
|
|
|
AdditionalSOs("additional-so",
|
|
|
|
cl::desc("Additional shared objects to load "
|
|
|
|
"into executing programs"));
|
2004-07-24 07:53:26 +00:00
|
|
|
|
2006-06-06 00:00:42 +00:00
|
|
|
cl::list<std::string>
|
2011-02-08 18:07:10 +00:00
|
|
|
AdditionalLinkerArgs("Xlinker",
|
2006-06-06 00:00:42 +00:00
|
|
|
cl::desc("Additional arguments to pass to the linker"));
|
2008-04-28 20:53:48 +00:00
|
|
|
|
2011-02-08 18:20:48 +00:00
|
|
|
cl::opt<std::string>
|
|
|
|
CustomCompileCommand("compile-command", cl::init("llc"),
|
|
|
|
cl::desc("Command to compile the bitcode (use with -compile-custom) "
|
|
|
|
"(default: llc)"));
|
|
|
|
|
2008-04-28 20:53:48 +00:00
|
|
|
cl::opt<std::string>
|
|
|
|
CustomExecCommand("exec-command", cl::init("simulate"),
|
|
|
|
cl::desc("Command to execute the bitcode (use with -run-custom) "
|
|
|
|
"(default: simulate)"));
|
2002-12-23 23:50:16 +00:00
|
|
|
}
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
2004-01-14 03:38:37 +00:00
|
|
|
// Anything specified after the --args option are taken as arguments to the
|
|
|
|
// program being debugged.
|
|
|
|
cl::list<std::string>
|
|
|
|
InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
|
2004-05-06 22:05:35 +00:00
|
|
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
2009-09-07 19:26:11 +00:00
|
|
|
|
|
|
|
cl::opt<std::string>
|
|
|
|
OutputPrefix("output-prefix", cl::init("bugpoint"),
|
|
|
|
cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
|
2008-12-08 04:02:47 +00:00
|
|
|
}
|
2004-05-04 21:09:16 +00:00
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
namespace {
|
2004-05-04 21:09:16 +00:00
|
|
|
cl::list<std::string>
|
|
|
|
ToolArgv("tool-args", cl::Positional, cl::desc("<tool arguments>..."),
|
2004-05-06 22:05:35 +00:00
|
|
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
2008-12-08 04:02:47 +00:00
|
|
|
|
|
|
|
cl::list<std::string>
|
|
|
|
SafeToolArgv("safe-tool-args", cl::Positional,
|
|
|
|
cl::desc("<safe-tool arguments>..."),
|
|
|
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
2009-03-02 23:13:18 +00:00
|
|
|
|
2010-05-10 07:38:37 +00:00
|
|
|
cl::opt<std::string>
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary("gcc", cl::init("gcc"),
|
2010-05-10 07:38:37 +00:00
|
|
|
cl::desc("The gcc binary to use. (default 'gcc')"));
|
|
|
|
|
2009-03-02 23:13:18 +00:00
|
|
|
cl::list<std::string>
|
|
|
|
GCCToolArgv("gcc-tool-args", cl::Positional,
|
|
|
|
cl::desc("<gcc-tool arguments>..."),
|
|
|
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
2004-01-14 03:38:37 +00:00
|
|
|
}
|
2003-07-30 20:15:44 +00:00
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// BugDriver method implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
/// initializeExecutionEnvironment - This method is used to set up the
|
|
|
|
/// environment for executing LLVM programs.
|
|
|
|
///
|
|
|
|
bool BugDriver::initializeExecutionEnvironment() {
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "Initializing execution environment: ";
|
2002-12-23 23:50:16 +00:00
|
|
|
|
2003-09-29 22:40:52 +00:00
|
|
|
// Create an instance of the AbstractInterpreter interface as specified on
|
|
|
|
// the command line
|
2008-12-08 04:02:47 +00:00
|
|
|
SafeInterpreter = 0;
|
2002-12-23 23:50:16 +00:00
|
|
|
std::string Message;
|
2004-05-04 21:09:16 +00:00
|
|
|
|
2003-05-03 03:19:41 +00:00
|
|
|
switch (InterpreterSel) {
|
2003-10-21 17:41:35 +00:00
|
|
|
case AutoPick:
|
|
|
|
InterpreterSel = RunCBE;
|
2008-12-08 04:02:47 +00:00
|
|
|
Interpreter =
|
2010-05-10 07:38:37 +00:00
|
|
|
AbstractInterpreter::createCBE(getToolName(), Message, GCCBinary,
|
|
|
|
&ToolArgv, &GCCToolArgv);
|
2003-10-21 17:41:35 +00:00
|
|
|
if (!Interpreter) {
|
|
|
|
InterpreterSel = RunJIT;
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
|
|
|
&ToolArgv);
|
2003-10-21 17:41:35 +00:00
|
|
|
}
|
|
|
|
if (!Interpreter) {
|
|
|
|
InterpreterSel = RunLLC;
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary, &ToolArgv,
|
2010-05-10 07:38:37 +00:00
|
|
|
&GCCToolArgv);
|
2003-10-21 17:41:35 +00:00
|
|
|
}
|
|
|
|
if (!Interpreter) {
|
|
|
|
InterpreterSel = RunLLI;
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createLLI(getToolName(), Message,
|
|
|
|
&ToolArgv);
|
2003-10-21 17:41:35 +00:00
|
|
|
}
|
|
|
|
if (!Interpreter) {
|
|
|
|
InterpreterSel = AutoPick;
|
|
|
|
Message = "Sorry, I can't automatically select an interpreter!\n";
|
|
|
|
}
|
|
|
|
break;
|
2003-10-14 21:59:36 +00:00
|
|
|
case RunLLI:
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createLLI(getToolName(), Message,
|
|
|
|
&ToolArgv);
|
2003-10-14 21:59:36 +00:00
|
|
|
break;
|
|
|
|
case RunLLC:
|
2010-03-16 06:41:47 +00:00
|
|
|
case RunLLCIA:
|
2008-12-08 04:02:47 +00:00
|
|
|
case LLC_Safe:
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary, &ToolArgv,
|
2010-05-10 07:38:37 +00:00
|
|
|
&GCCToolArgv,
|
2010-03-16 06:41:47 +00:00
|
|
|
InterpreterSel == RunLLCIA);
|
2003-10-14 21:59:36 +00:00
|
|
|
break;
|
|
|
|
case RunJIT:
|
2004-05-04 21:09:16 +00:00
|
|
|
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
|
|
|
&ToolArgv);
|
2003-10-14 21:59:36 +00:00
|
|
|
break;
|
|
|
|
case RunCBE:
|
2006-09-15 21:29:15 +00:00
|
|
|
case CBE_bug:
|
|
|
|
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary, &ToolArgv,
|
2010-05-10 07:38:37 +00:00
|
|
|
&GCCToolArgv);
|
2003-10-14 21:59:36 +00:00
|
|
|
break;
|
2011-02-08 18:20:48 +00:00
|
|
|
case CompileCustom:
|
|
|
|
Interpreter =
|
|
|
|
AbstractInterpreter::createCustomCompiler(Message, CustomCompileCommand);
|
|
|
|
break;
|
2008-04-28 20:53:48 +00:00
|
|
|
case Custom:
|
2011-02-08 18:20:48 +00:00
|
|
|
Interpreter =
|
|
|
|
AbstractInterpreter::createCustomExecutor(Message, CustomExecCommand);
|
2008-04-28 20:53:48 +00:00
|
|
|
break;
|
2003-05-03 03:19:41 +00:00
|
|
|
default:
|
2003-09-29 22:40:52 +00:00
|
|
|
Message = "Sorry, this back-end is not supported by bugpoint right now!\n";
|
2003-05-03 03:19:41 +00:00
|
|
|
break;
|
2002-12-23 23:50:16 +00:00
|
|
|
}
|
2008-06-12 13:09:43 +00:00
|
|
|
if (!Interpreter)
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << Message;
|
2008-06-12 13:09:43 +00:00
|
|
|
else // Display informational messages on stdout instead of stderr
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << Message;
|
2002-12-23 23:50:16 +00:00
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
std::string Path = SafeInterpreterPath;
|
|
|
|
if (Path.empty())
|
|
|
|
Path = getToolName();
|
|
|
|
std::vector<std::string> SafeToolArgs = SafeToolArgv;
|
|
|
|
switch (SafeInterpreterSel) {
|
|
|
|
case AutoPick:
|
|
|
|
// In "cbe-bug" mode, default to using LLC as the "safe" backend.
|
|
|
|
if (!SafeInterpreter &&
|
|
|
|
InterpreterSel == CBE_bug) {
|
|
|
|
SafeInterpreterSel = RunLLC;
|
|
|
|
SafeToolArgs.push_back("--relocation-model=pic");
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary,
|
2009-03-02 23:13:18 +00:00
|
|
|
&SafeToolArgs,
|
|
|
|
&GCCToolArgv);
|
2008-12-08 04:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// In "llc-safe" mode, default to using LLC as the "safe" backend.
|
|
|
|
if (!SafeInterpreter &&
|
|
|
|
InterpreterSel == LLC_Safe) {
|
|
|
|
SafeInterpreterSel = RunLLC;
|
|
|
|
SafeToolArgs.push_back("--relocation-model=pic");
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary,
|
2009-03-02 23:13:18 +00:00
|
|
|
&SafeToolArgs,
|
|
|
|
&GCCToolArgv);
|
2008-12-08 04:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Pick a backend that's different from the test backend. The JIT and
|
|
|
|
// LLC backends share a lot of code, so prefer to use the CBE as the
|
|
|
|
// safe back-end when testing them.
|
|
|
|
if (!SafeInterpreter &&
|
|
|
|
InterpreterSel != RunCBE) {
|
|
|
|
SafeInterpreterSel = RunCBE;
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,
|
2010-05-10 07:38:37 +00:00
|
|
|
GCCBinary,
|
2009-03-02 23:13:18 +00:00
|
|
|
&SafeToolArgs,
|
|
|
|
&GCCToolArgv);
|
2008-12-08 04:02:47 +00:00
|
|
|
}
|
|
|
|
if (!SafeInterpreter &&
|
|
|
|
InterpreterSel != RunLLC &&
|
|
|
|
InterpreterSel != RunJIT) {
|
|
|
|
SafeInterpreterSel = RunLLC;
|
|
|
|
SafeToolArgs.push_back("--relocation-model=pic");
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
|
2011-02-08 18:07:10 +00:00
|
|
|
GCCBinary,
|
2009-03-02 23:13:18 +00:00
|
|
|
&SafeToolArgs,
|
|
|
|
&GCCToolArgv);
|
2008-12-08 04:02:47 +00:00
|
|
|
}
|
|
|
|
if (!SafeInterpreter) {
|
|
|
|
SafeInterpreterSel = AutoPick;
|
|
|
|
Message = "Sorry, I can't automatically select an interpreter!\n";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RunLLC:
|
2010-03-16 06:41:47 +00:00
|
|
|
case RunLLCIA:
|
2008-12-08 04:02:47 +00:00
|
|
|
SafeToolArgs.push_back("--relocation-model=pic");
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
|
2010-05-10 07:38:37 +00:00
|
|
|
GCCBinary, &SafeToolArgs,
|
2010-03-16 06:41:47 +00:00
|
|
|
&GCCToolArgv,
|
|
|
|
SafeInterpreterSel == RunLLCIA);
|
2008-12-08 04:02:47 +00:00
|
|
|
break;
|
|
|
|
case RunCBE:
|
2009-08-05 20:21:17 +00:00
|
|
|
SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,
|
2010-05-10 07:38:37 +00:00
|
|
|
GCCBinary, &SafeToolArgs,
|
2009-03-02 23:13:18 +00:00
|
|
|
&GCCToolArgv);
|
2008-12-08 04:02:47 +00:00
|
|
|
break;
|
|
|
|
case Custom:
|
2011-02-08 18:20:48 +00:00
|
|
|
SafeInterpreter =
|
|
|
|
AbstractInterpreter::createCustomExecutor(Message, CustomExecCommand);
|
2008-12-08 04:02:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Message = "Sorry, this back-end is not supported by bugpoint as the "
|
|
|
|
"\"safe\" backend right now!\n";
|
|
|
|
break;
|
2004-02-18 20:52:02 +00:00
|
|
|
}
|
2009-07-16 15:30:09 +00:00
|
|
|
if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); }
|
2011-02-08 18:07:10 +00:00
|
|
|
|
2010-05-10 07:38:37 +00:00
|
|
|
gcc = GCC::create(Message, GCCBinary, &GCCToolArgv);
|
2009-07-16 15:30:09 +00:00
|
|
|
if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); }
|
2003-07-24 21:59:10 +00:00
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
// If there was an error creating the selected interpreter, quit with error.
|
|
|
|
return Interpreter == 0;
|
|
|
|
}
|
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
/// compileProgram - Try to compile the specified module, returning false and
|
|
|
|
/// setting Error if an error occurs. This is used for code generation
|
|
|
|
/// crash testing.
|
2004-02-18 23:25:22 +00:00
|
|
|
///
|
2010-08-05 03:00:22 +00:00
|
|
|
void BugDriver::compileProgram(Module *M, std::string *Error) const {
|
2007-07-04 21:55:50 +00:00
|
|
|
// Emit the program to a bitcode file...
|
2009-09-07 19:26:11 +00:00
|
|
|
sys::Path BitcodeFile (OutputPrefix + "-test-program.bc");
|
2006-08-23 20:34:57 +00:00
|
|
|
std::string ErrMsg;
|
2010-04-12 05:08:25 +00:00
|
|
|
if (BitcodeFile.makeUnique(true, &ErrMsg)) {
|
2011-02-08 18:07:10 +00:00
|
|
|
errs() << ToolName << ": Error making unique filename: " << ErrMsg
|
2009-07-15 16:35:29 +00:00
|
|
|
<< "\n";
|
2006-08-23 20:34:57 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2009-08-23 22:45:37 +00:00
|
|
|
if (writeProgramToFile(BitcodeFile.str(), M)) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << ToolName << ": Error emitting bitcode to file '"
|
2009-08-23 22:45:37 +00:00
|
|
|
<< BitcodeFile.str() << "'!\n";
|
2004-02-18 23:25:22 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
// Remove the temporary bitcode file when we are done.
|
2011-03-31 13:04:19 +00:00
|
|
|
FileRemover BitcodeFileRemover(BitcodeFile.str(), !SaveTemps);
|
2004-02-18 23:25:22 +00:00
|
|
|
|
|
|
|
// Actually compile the program!
|
2010-05-24 07:49:55 +00:00
|
|
|
Interpreter->compileProgram(BitcodeFile.str(), Error, Timeout, MemoryLimit);
|
2004-02-18 23:25:22 +00:00
|
|
|
}
|
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
|
|
|
|
/// executeProgram - This method runs "Program", capturing the output of the
|
|
|
|
/// program to a file, returning the filename of the file. A recommended
|
|
|
|
/// filename may be optionally specified.
|
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
std::string BugDriver::executeProgram(const Module *Program,
|
|
|
|
std::string OutputFile,
|
2007-07-04 21:55:50 +00:00
|
|
|
std::string BitcodeFile,
|
2003-10-14 21:59:36 +00:00
|
|
|
const std::string &SharedObj,
|
2010-04-12 05:08:25 +00:00
|
|
|
AbstractInterpreter *AI,
|
2010-07-31 14:34:49 +00:00
|
|
|
std::string *Error) const {
|
2003-10-14 21:59:36 +00:00
|
|
|
if (AI == 0) AI = Interpreter;
|
|
|
|
assert(AI && "Interpreter should have been created already!");
|
2007-07-04 21:55:50 +00:00
|
|
|
bool CreatedBitcode = false;
|
2006-08-23 20:34:57 +00:00
|
|
|
std::string ErrMsg;
|
2007-07-04 21:55:50 +00:00
|
|
|
if (BitcodeFile.empty()) {
|
|
|
|
// Emit the program to a bitcode file...
|
2009-09-07 19:26:11 +00:00
|
|
|
sys::Path uniqueFilename(OutputPrefix + "-test-program.bc");
|
2006-08-23 20:34:57 +00:00
|
|
|
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << ToolName << ": Error making unique filename: "
|
|
|
|
<< ErrMsg << "!\n";
|
2006-08-23 20:34:57 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2009-08-23 22:45:37 +00:00
|
|
|
BitcodeFile = uniqueFilename.str();
|
2002-12-23 23:50:16 +00:00
|
|
|
|
2007-07-04 21:55:50 +00:00
|
|
|
if (writeProgramToFile(BitcodeFile, Program)) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << ToolName << ": Error emitting bitcode to file '"
|
|
|
|
<< BitcodeFile << "'!\n";
|
2002-12-23 23:50:16 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2007-07-04 21:55:50 +00:00
|
|
|
CreatedBitcode = true;
|
2002-12-23 23:50:16 +00:00
|
|
|
}
|
|
|
|
|
2007-07-04 21:55:50 +00:00
|
|
|
// Remove the temporary bitcode file when we are done.
|
2010-04-10 23:18:13 +00:00
|
|
|
sys::Path BitcodePath(BitcodeFile);
|
2011-03-31 13:04:19 +00:00
|
|
|
FileRemover BitcodeFileRemover(BitcodePath.str(),
|
|
|
|
CreatedBitcode && !SaveTemps);
|
2004-02-18 22:01:21 +00:00
|
|
|
|
2009-09-07 19:26:11 +00:00
|
|
|
if (OutputFile.empty()) OutputFile = OutputPrefix + "-execution-output";
|
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
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
// Check to see if this is a valid output filename...
|
2004-12-15 01:53:08 +00:00
|
|
|
sys::Path uniqueFile(OutputFile);
|
2006-08-23 20:34:57 +00:00
|
|
|
if (uniqueFile.makeUnique(true, &ErrMsg)) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << ToolName << ": Error making unique filename: "
|
|
|
|
<< ErrMsg << "\n";
|
2006-08-23 20:34:57 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2009-08-23 22:45:37 +00:00
|
|
|
OutputFile = uniqueFile.str();
|
2002-12-23 23:50:16 +00:00
|
|
|
|
2003-10-14 21:59:36 +00:00
|
|
|
// Figure out which shared objects to run, if any.
|
2003-10-14 22:24:31 +00:00
|
|
|
std::vector<std::string> SharedObjs(AdditionalSOs);
|
2003-10-14 21:59:36 +00:00
|
|
|
if (!SharedObj.empty())
|
|
|
|
SharedObjs.push_back(SharedObj);
|
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
int RetVal = AI->ExecuteProgram(BitcodeFile, InputArgv, InputFile, OutputFile,
|
|
|
|
Error, AdditionalLinkerArgs, SharedObjs,
|
2008-12-08 04:02:47 +00:00
|
|
|
Timeout, MemoryLimit);
|
2010-04-12 05:08:25 +00:00
|
|
|
if (!Error->empty())
|
|
|
|
return OutputFile;
|
2004-07-24 07:53:26 +00:00
|
|
|
|
|
|
|
if (RetVal == -1) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << "<timeout>";
|
2004-07-24 07:53:26 +00:00
|
|
|
static bool FirstTimeout = true;
|
|
|
|
if (FirstTimeout) {
|
2009-07-16 15:30:09 +00:00
|
|
|
outs() << "\n"
|
2004-07-24 07:53:26 +00:00
|
|
|
"*** Program execution timed out! This mechanism is designed to handle\n"
|
|
|
|
" programs stuck in infinite loops gracefully. The -timeout option\n"
|
|
|
|
" can be used to change the timeout threshold or disable it completely\n"
|
|
|
|
" (with -timeout=0). This message is only displayed once.\n";
|
|
|
|
FirstTimeout = false;
|
|
|
|
}
|
|
|
|
}
|
2003-10-14 21:59:36 +00:00
|
|
|
|
2006-11-28 07:04:10 +00:00
|
|
|
if (AppendProgramExitCode) {
|
|
|
|
std::ofstream outFile(OutputFile.c_str(), std::ios_base::app);
|
|
|
|
outFile << "exit " << RetVal << '\n';
|
|
|
|
outFile.close();
|
|
|
|
}
|
|
|
|
|
2002-12-23 23:50:16 +00:00
|
|
|
// Return the filename we captured the output to.
|
|
|
|
return OutputFile;
|
|
|
|
}
|
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
/// executeProgramSafely - Used to create reference output with the "safe"
|
2004-02-11 18:37:32 +00:00
|
|
|
/// backend, if reference output is not provided.
|
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
std::string BugDriver::executeProgramSafely(const Module *Program,
|
|
|
|
std::string OutputFile,
|
2010-07-31 14:34:49 +00:00
|
|
|
std::string *Error) const {
|
2010-07-30 14:19:00 +00:00
|
|
|
return executeProgram(Program, OutputFile, "", "", SafeInterpreter, Error);
|
2004-02-11 18:37:32 +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
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string BugDriver::compileSharedObject(const std::string &BitcodeFile,
|
|
|
|
std::string &Error) {
|
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
|
|
|
assert(Interpreter && "Interpreter should have been created already!");
|
2006-09-15 21:29:15 +00:00
|
|
|
sys::Path OutputFile;
|
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
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
// Using the known-good backend.
|
2010-04-12 05:08:25 +00:00
|
|
|
GCC::FileType FT = SafeInterpreter->OutputCode(BitcodeFile, OutputFile,
|
|
|
|
Error);
|
|
|
|
if (!Error.empty())
|
|
|
|
return "";
|
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 21:09:11 +00:00
|
|
|
std::string SharedObjectFile;
|
2010-04-12 05:08:25 +00:00
|
|
|
bool Failure = gcc->MakeSharedObject(OutputFile.str(), FT, SharedObjectFile,
|
|
|
|
AdditionalLinkerArgs, Error);
|
|
|
|
if (!Error.empty())
|
|
|
|
return "";
|
|
|
|
if (Failure)
|
2003-10-14 21:09:11 +00:00
|
|
|
exit(1);
|
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
|
|
|
|
|
|
|
// Remove the intermediate C file
|
2006-09-15 21:29:15 +00:00
|
|
|
OutputFile.eraseFromDisk();
|
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-19 21:54:13 +00:00
|
|
|
return "./" + SharedObjectFile;
|
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
|
|
|
}
|
|
|
|
|
2006-08-15 16:40:49 +00:00
|
|
|
/// createReferenceFile - calls compileProgram and then records the output
|
2011-02-08 18:07:10 +00:00
|
|
|
/// into ReferenceOutputFile. Returns true if reference file created, false
|
2006-08-15 16:40:49 +00:00
|
|
|
/// otherwise. Note: initializeExecutionEnvironment should be called BEFORE
|
|
|
|
/// this function.
|
|
|
|
///
|
2006-09-15 21:29:15 +00:00
|
|
|
bool BugDriver::createReferenceFile(Module *M, const std::string &Filename) {
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string Error;
|
|
|
|
compileProgram(Program, &Error);
|
|
|
|
if (!Error.empty())
|
2006-08-15 16:40:49 +00:00
|
|
|
return false;
|
2010-04-12 05:08:25 +00:00
|
|
|
|
2010-07-30 14:19:00 +00:00
|
|
|
ReferenceOutputFile = executeProgramSafely(Program, Filename, &Error);
|
2010-04-12 05:08:25 +00:00
|
|
|
if (!Error.empty()) {
|
|
|
|
errs() << Error;
|
2008-12-08 04:02:47 +00:00
|
|
|
if (Interpreter != SafeInterpreter) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << "*** There is a bug running the \"safe\" backend. Either"
|
|
|
|
<< " debug it (for example with the -run-cbe bugpoint option,"
|
|
|
|
<< " if CBE is being used as the \"safe\" backend), or fix the"
|
|
|
|
<< " error some other way.\n";
|
2006-08-15 16:40:49 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-12 05:08:25 +00:00
|
|
|
outs() << "\nReference output is: " << ReferenceOutputFile << "\n\n";
|
2006-08-15 16:40:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
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
|
|
|
|
2006-08-15 16:40:49 +00:00
|
|
|
/// diffProgram - This method executes the specified module and diffs the
|
|
|
|
/// output against the file specified by ReferenceOutputFile. If the output
|
2010-04-12 05:08:25 +00:00
|
|
|
/// is different, 1 is returned. If there is a problem with the code
|
2011-05-11 16:31:24 +00:00
|
|
|
/// generator (e.g., llc crashes), this will set ErrMsg.
|
2002-12-23 23:50:16 +00:00
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
bool BugDriver::diffProgram(const Module *Program,
|
|
|
|
const std::string &BitcodeFile,
|
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
|
|
|
const std::string &SharedObject,
|
2010-04-12 05:08:25 +00:00
|
|
|
bool RemoveBitcode,
|
2010-07-31 14:34:49 +00:00
|
|
|
std::string *ErrMsg) const {
|
2002-12-23 23:50:16 +00:00
|
|
|
// Execute the program, generating an output file...
|
2010-07-30 14:19:00 +00:00
|
|
|
sys::Path Output(executeProgram(Program, "", BitcodeFile, SharedObject, 0,
|
|
|
|
ErrMsg));
|
2010-04-12 05:08:25 +00:00
|
|
|
if (!ErrMsg->empty())
|
|
|
|
return false;
|
2004-02-11 18:37:32 +00:00
|
|
|
|
2003-08-01 20:29:45 +00:00
|
|
|
std::string Error;
|
2002-12-23 23:50:16 +00:00
|
|
|
bool FilesDifferent = false;
|
2005-01-23 03:45:26 +00:00
|
|
|
if (int Diff = DiffFilesWithTolerance(sys::Path(ReferenceOutputFile),
|
2009-08-23 22:45:37 +00:00
|
|
|
sys::Path(Output.str()),
|
2005-01-23 03:45:26 +00:00
|
|
|
AbsTolerance, RelTolerance, &Error)) {
|
|
|
|
if (Diff == 2) {
|
2009-07-15 16:35:29 +00:00
|
|
|
errs() << "While diffing output: " << Error << '\n';
|
2003-08-01 20:29:45 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FilesDifferent = true;
|
|
|
|
}
|
2009-07-10 21:39:28 +00:00
|
|
|
else {
|
|
|
|
// Remove the generated output if there are no differences.
|
|
|
|
Output.eraseFromDisk();
|
|
|
|
}
|
2002-12-23 23:50:16 +00:00
|
|
|
|
2007-07-04 21:55:50 +00:00
|
|
|
// Remove the bitcode file if we are supposed to.
|
|
|
|
if (RemoveBitcode)
|
|
|
|
sys::Path(BitcodeFile).eraseFromDisk();
|
2002-12-23 23:50:16 +00:00
|
|
|
return FilesDifferent;
|
|
|
|
}
|
2003-07-28 19:16:14 +00:00
|
|
|
|
|
|
|
bool BugDriver::isExecutingJIT() {
|
|
|
|
return InterpreterSel == RunJIT;
|
|
|
|
}
|
2003-11-11 22:41:34 +00:00
|
|
|
|