aboutsummaryrefslogtreecommitdiff
path: root/tools/bugpoint/BugDriver.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-12-22 20:02:55 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-12-22 20:02:55 +0000
commitc4bb052ecccfafa0ffa928d0b061db35734ee2ee (patch)
tree112af45c46e45f8bdca1007868b276d1d13a6bf7 /tools/bugpoint/BugDriver.cpp
parentd555f413cddb554203e3584047116fd97f6383d6 (diff)
For PR351:
Generally, remove use of fork/exec from bugpoint in favor of the portable sys::Program::ExecuteAndWait method. This change requires two new options to bugpoint to tell it that it is running in "child" mode. In this mode, it reads its input and runs the passes. The result code signals to the parent instance of bugpoint what happened (success, fail, crash). This change should make bugpoint usable on Win32 systems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/BugDriver.cpp')
-rw-r--r--tools/bugpoint/BugDriver.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 17e3374117..bd558db665 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -62,9 +62,9 @@ std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
return Result;
}
-BugDriver::BugDriver(const char *toolname)
+BugDriver::BugDriver(const char *toolname, bool as_child)
: ToolName(toolname), ReferenceOutputFile(OutputFile),
- Program(0), Interpreter(0), cbe(0), gcc(0) {}
+ Program(0), Interpreter(0), cbe(0), gcc(0), run_as_child(as_child) {}
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
@@ -97,13 +97,15 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
// Load the first input file...
Program = ParseInputFile(Filenames[0]);
if (Program == 0) return true;
- std::cout << "Read input file : '" << Filenames[0] << "'\n";
+ if (!run_as_child)
+ std::cout << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::auto_ptr<Module> M(ParseInputFile(Filenames[i]));
if (M.get() == 0) return true;
- std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
+ if (!run_as_child)
+ std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
std::string ErrorMessage;
if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) {
std::cerr << ToolName << ": error linking in '" << Filenames[i] << "': "
@@ -112,7 +114,8 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
}
}
- std::cout << "*** All input ok\n";
+ if (!run_as_child)
+ std::cout << "*** All input ok\n";
// All input files read successfully!
return false;
@@ -124,12 +127,21 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
/// variables are set up from command line arguments.
///
bool BugDriver::run() {
- // 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 decision by trying to run all of the passes on the
- // the input program, which should generate a bytecode file. If it does
- // generate a bytecode file, then we know the compiler didn't crash, so try
- // to diagnose a miscompilation.
+ // The first thing to do is determine if we're running as a child. If we are,
+ // then what to do is very narrow. This form of invocation is only called
+ // from the runPasses method to actually run those passes in a child process.
+ if (run_as_child) {
+ // Execute the passes
+ return runPassesAsChild(PassesToRun);
+ }
+
+ // 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
+ // decision by trying to run all of the passes on the the input program,
+ // which should generate a bytecode file. If it does generate a bytecode
+ // file, then we know the compiler didn't crash, so try to diagnose a
+ // miscompilation.
if (!PassesToRun.empty()) {
std::cout << "Running selected passes on program to test for crash: ";
if (runPasses(PassesToRun))