summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/BugDriver.cpp10
-rw-r--r--tools/bugpoint/CrashDebugger.cpp11
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp36
-rw-r--r--tools/bugpoint/ExtractFunction.cpp14
-rw-r--r--tools/bugpoint/FindBugs.cpp2
-rw-r--r--tools/bugpoint/ListReducer.h14
-rw-r--r--tools/bugpoint/Miscompilation.cpp79
-rw-r--r--tools/bugpoint/ToolRunner.cpp70
-rw-r--r--tools/bugpoint/bugpoint.cpp20
9 files changed, 129 insertions, 127 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 269bf5fb09..ac5de15589 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -117,13 +117,13 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
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] << "': "
- << ErrorMessage << '\n';
+ errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
+ << ErrorMessage << '\n';
return true;
}
}
} catch (const std::string &Error) {
- std::cerr << ToolName << ": error reading input '" << Error << "'\n";
+ errs() << ToolName << ": error reading input '" << Error << "'\n";
return true;
}
@@ -209,7 +209,7 @@ bool BugDriver::run() {
return debugMiscompilation();
}
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.what();
+ errs() << TEE.what();
return debugCodeGeneratorCrash();
}
@@ -218,7 +218,7 @@ bool BugDriver::run() {
try {
return debugCodeGenerator();
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.what();
+ errs() << TEE.what();
return debugCodeGeneratorCrash();
}
}
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 3084857f1a..34efdc119d 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -28,6 +28,7 @@
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/CommandLine.h"
+#include <iostream>
#include <fstream>
#include <set>
using namespace llvm;
@@ -75,8 +76,8 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
BD.Program = ParseInputFile(PrefixOutput.toString(), BD.getContext());
if (BD.Program == 0) {
- std::cerr << BD.getToolName() << ": Error reading bitcode file '"
- << PrefixOutput << "'!\n";
+ errs() << BD.getToolName() << ": Error reading bitcode file '"
+ << PrefixOutput << "'!\n";
exit(1);
}
PrefixOutput.eraseFromDisk();
@@ -631,10 +632,10 @@ bool BugDriver::debugOptimizerCrash(const std::string &ID) {
static bool TestForCodeGenCrash(BugDriver &BD, Module *M) {
try {
BD.compileProgram(M);
- std::cerr << '\n';
+ errs() << '\n';
return false;
} catch (ToolExecutionError &) {
- std::cerr << "<crash>\n";
+ errs() << "<crash>\n";
return true; // Tool is still crashing.
}
}
@@ -643,7 +644,7 @@ static bool TestForCodeGenCrash(BugDriver &BD, Module *M) {
/// crashes on an input. It attempts to reduce the input as much as possible
/// while still causing the code generator to crash.
bool BugDriver::debugCodeGeneratorCrash() {
- std::cerr << "*** Debugging code generator crash!\n";
+ errs() << "*** Debugging code generator crash!\n";
return DebugACrash(*this, TestForCodeGenCrash);
}
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index 854aeb817f..6e5b7a0514 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -186,7 +186,7 @@ bool BugDriver::initializeExecutionEnvironment() {
break;
}
if (!Interpreter)
- std::cerr << Message;
+ errs() << Message;
else // Display informational messages on stdout instead of stderr
std::cout << Message;
@@ -278,13 +278,13 @@ void BugDriver::compileProgram(Module *M) {
sys::Path BitcodeFile ("bugpoint-test-program.bc");
std::string ErrMsg;
if (BitcodeFile.makeUnique(true,&ErrMsg)) {
- std::cerr << ToolName << ": Error making unique filename: " << ErrMsg
- << "\n";
+ errs() << ToolName << ": Error making unique filename: " << ErrMsg
+ << "\n";
exit(1);
}
if (writeProgramToFile(BitcodeFile.toString(), M)) {
- std::cerr << ToolName << ": Error emitting bitcode to file '"
- << BitcodeFile << "'!\n";
+ errs() << ToolName << ": Error emitting bitcode to file '"
+ << BitcodeFile << "'!\n";
exit(1);
}
@@ -313,15 +313,15 @@ std::string BugDriver::executeProgram(std::string OutputFile,
// Emit the program to a bitcode file...
sys::Path uniqueFilename("bugpoint-test-program.bc");
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
- std::cerr << ToolName << ": Error making unique filename: "
- << ErrMsg << "!\n";
+ errs() << ToolName << ": Error making unique filename: "
+ << ErrMsg << "!\n";
exit(1);
}
BitcodeFile = uniqueFilename.toString();
if (writeProgramToFile(BitcodeFile, Program)) {
- std::cerr << ToolName << ": Error emitting bitcode to file '"
- << BitcodeFile << "'!\n";
+ errs() << ToolName << ": Error emitting bitcode to file '"
+ << BitcodeFile << "'!\n";
exit(1);
}
CreatedBitcode = true;
@@ -336,8 +336,8 @@ std::string BugDriver::executeProgram(std::string OutputFile,
// Check to see if this is a valid output filename...
sys::Path uniqueFile(OutputFile);
if (uniqueFile.makeUnique(true, &ErrMsg)) {
- std::cerr << ToolName << ": Error making unique filename: "
- << ErrMsg << "\n";
+ errs() << ToolName << ": Error making unique filename: "
+ << ErrMsg << "\n";
exit(1);
}
OutputFile = uniqueFile.toString();
@@ -352,7 +352,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
Timeout, MemoryLimit);
if (RetVal == -1) {
- std::cerr << "<timeout>";
+ errs() << "<timeout>";
static bool FirstTimeout = true;
if (FirstTimeout) {
std::cout << "\n"
@@ -420,12 +420,12 @@ bool BugDriver::createReferenceFile(Module *M, const std::string &Filename) {
ReferenceOutputFile = executeProgramSafely(Filename);
std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.what();
+ errs() << TEE.what();
if (Interpreter != SafeInterpreter) {
- std::cerr << "*** 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";
+ 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";
}
return false;
}
@@ -452,7 +452,7 @@ bool BugDriver::diffProgram(const std::string &BitcodeFile,
sys::Path(Output.toString()),
AbsTolerance, RelTolerance, &Error)) {
if (Diff == 2) {
- std::cerr << "While diffing output: " << Error << '\n';
+ errs() << "While diffing output: " << Error << '\n';
exit(1);
}
FilesDifferent = true;
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 3df130771f..7bdba50791 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -127,7 +127,7 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
Module *New = runPassesOn(M, CleanupPasses);
if (New == 0) {
- std::cerr << "Final cleanups failed. Sorry. :( Please report a bug!\n";
+ errs() << "Final cleanups failed. Sorry. :( Please report a bug!\n";
return M;
}
delete M;
@@ -288,9 +288,9 @@ llvm::SplitFunctionsOutOfModule(Module *M,
std::set<Function *> TestFunctions;
for (unsigned i = 0, e = F.size(); i != e; ++i) {
Function *TNOF = cast<Function>(ValueMap[F[i]]);
- DEBUG(std::cerr << "Removing function ");
- DEBUG(WriteAsOperand(std::cerr, TNOF, false));
- DEBUG(std::cerr << "\n");
+ DEBUG(errs() << "Removing function ");
+ DEBUG(WriteAsOperand(errs(), TNOF, false));
+ DEBUG(errs() << "\n");
TestFunctions.insert(cast<Function>(NewValueMap[TNOF]));
DeleteFunctionBody(TNOF); // Function is now external in this module!
}
@@ -328,7 +328,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
std::string ErrMsg;
if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
std::cout << "*** Basic Block extraction failed!\n";
- std::cerr << "Error creating temporary file: " << ErrMsg << "\n";
+ errs() << "Error creating temporary file: " << ErrMsg << "\n";
M = swapProgramIn(M);
EmitProgressBitcode("basicblockextractfail", true);
swapProgramIn(M);
@@ -339,8 +339,8 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
std::ofstream BlocksToNotExtractFile(uniqueFilename.c_str());
if (!BlocksToNotExtractFile) {
std::cout << "*** Basic Block extraction failed!\n";
- std::cerr << "Error writing list of blocks to not extract: " << ErrMsg
- << "\n";
+ errs() << "Error writing list of blocks to not extract: " << ErrMsg
+ << "\n";
M = swapProgramIn(M);
EmitProgressBitcode("basicblockextractfail", true);
swapProgramIn(M);
diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp
index e42cce47ba..a28c1b667d 100644
--- a/tools/bugpoint/FindBugs.cpp
+++ b/tools/bugpoint/FindBugs.cpp
@@ -97,7 +97,7 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses) {
std::cout << "\n*** diff'd output matches!\n";
}
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.what();
+ errs() << TEE.what();
debugCodeGeneratorCrash();
return true;
}
diff --git a/tools/bugpoint/ListReducer.h b/tools/bugpoint/ListReducer.h
index de3f389200..8036d1f544 100644
--- a/tools/bugpoint/ListReducer.h
+++ b/tools/bugpoint/ListReducer.h
@@ -15,8 +15,8 @@
#ifndef BUGPOINT_LIST_REDUCER_H
#define BUGPOINT_LIST_REDUCER_H
+#include "llvm/Support/raw_ostream.h"
#include <vector>
-#include <iostream>
#include <cstdlib>
#include <algorithm>
@@ -58,7 +58,7 @@ struct ListReducer {
case KeepSuffix:
// cannot be reached!
- std::cerr << "bugpoint ListReducer internal error: selected empty set.\n";
+ errs() << "bugpoint ListReducer internal error: selected empty set.\n";
abort();
case NoFailure:
@@ -77,7 +77,7 @@ Backjump:
while (MidTop > 1) { // Binary split reduction loop
// Halt if the user presses ctrl-c.
if (BugpointIsInterrupted) {
- std::cerr << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
+ errs() << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
return true;
}
@@ -88,7 +88,7 @@ Backjump:
NumOfIterationsWithoutProgress > MaxIterations) {
std::vector<ElTy> ShuffledList(TheList);
std::random_shuffle(ShuffledList.begin(), ShuffledList.end());
- std::cerr << "\n\n*** Testing shuffled set...\n\n";
+ errs() << "\n\n*** Testing shuffled set...\n\n";
// Check that random shuffle doesn't loose the bug
if (doTest(ShuffledList, empty) == KeepPrefix) {
// If the bug is still here, use the shuffled list.
@@ -97,10 +97,10 @@ Backjump:
// Must increase the shuffling treshold to avoid the small
// probability of inifinite looping without making progress.
MaxIterations += 2;
- std::cerr << "\n\n*** Shuffling does not hide the bug...\n\n";
+ errs() << "\n\n*** Shuffling does not hide the bug...\n\n";
} else {
ShufflingEnabled = false; // Disable shuffling further on
- std::cerr << "\n\n*** Shuffling hides the bug...\n\n";
+ errs() << "\n\n*** Shuffling hides the bug...\n\n";
}
NumOfIterationsWithoutProgress = 0;
}
@@ -160,7 +160,7 @@ Backjump:
for (unsigned i = 1; i < TheList.size()-1; ++i) { // Check interior elts
if (BugpointIsInterrupted) {
- std::cerr << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
+ errs() << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
return true;
}
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index c655e71427..efa253823b 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -26,6 +26,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Config/config.h" // for HAVE_LINK_R
+#include <iostream>
using namespace llvm;
namespace llvm {
@@ -61,8 +62,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
std::string BitcodeResult;
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
- std::cerr << " Error running this sequence of passes"
- << " on the input program!\n";
+ errs() << " Error running this sequence of passes"
+ << " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
@@ -72,8 +73,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) {
std::cout << " nope.\n";
if (Suffix.empty()) {
- std::cerr << BD.getToolName() << ": I'm confused: the test fails when "
- << "no passes are run, nondeterministic program?\n";
+ errs() << BD.getToolName() << ": I'm confused: the test fails when "
+ << "no passes are run, nondeterministic program?\n";
exit(1);
}
return KeepSuffix; // Miscompilation detected!
@@ -94,8 +95,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// prefix passes, then discard the prefix passes.
//
if (BD.runPasses(Prefix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
- std::cerr << " Error running this sequence of passes"
- << " on the input program!\n";
+ errs() << " Error running this sequence of passes"
+ << " on the input program!\n";
BD.setPassesToRun(Prefix);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
@@ -114,8 +115,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
//
Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext());
if (PrefixOutput == 0) {
- std::cerr << BD.getToolName() << ": Error reading bitcode file '"
- << BitcodeResult << "'!\n";
+ errs() << BD.getToolName() << ": Error reading bitcode file '"
+ << BitcodeResult << "'!\n";
exit(1);
}
sys::Path(BitcodeResult).eraseFromDisk(); // No longer need the file on disk
@@ -130,8 +131,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
- std::cerr << " Error running this sequence of passes"
- << " on the input program!\n";
+ errs() << " Error running this sequence of passes"
+ << " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
@@ -187,8 +188,8 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2,
M2 = CloneModule(M2);
}
if (Linker::LinkModules(M1, M2, &ErrorMsg)) {
- std::cerr << BD.getToolName() << ": Error linking modules together:"
- << ErrorMsg << '\n';
+ errs() << BD.getToolName() << ": Error linking modules together:"
+ << ErrorMsg << '\n';
exit(1);
}
delete M2; // We are done with this module.
@@ -279,7 +280,7 @@ static bool ExtractLoops(BugDriver &BD,
return MadeChange;
}
- std::cerr << "Extracted a loop from the breaking portion of the program.\n";
+ errs() << "Extracted a loop from the breaking portion of the program.\n";
// Bugpoint is intentionally not very trusting of LLVM transformations. In
// particular, we're not going to assume that the loop extractor works, so
@@ -291,16 +292,16 @@ static bool ExtractLoops(BugDriver &BD,
BD.switchToInterpreter(AI);
// Merged program doesn't work anymore!
- std::cerr << " *** ERROR: Loop extraction broke the program. :("
- << " Please report a bug!\n";
- std::cerr << " Continuing on with un-loop-extracted version.\n";
+ errs() << " *** ERROR: Loop extraction broke the program. :("
+ << " Please report a bug!\n";
+ errs() << " Continuing on with un-loop-extracted version.\n";
BD.writeProgramToFile("bugpoint-loop-extract-fail-tno.bc", ToNotOptimize);
BD.writeProgramToFile("bugpoint-loop-extract-fail-to.bc", ToOptimize);
BD.writeProgramToFile("bugpoint-loop-extract-fail-to-le.bc",
ToOptimizeLoopExtracted);
- std::cerr << "Please submit the bugpoint-loop-extract-fail-*.bc files.\n";
+ errs() << "Please submit the bugpoint-loop-extract-fail-*.bc files.\n";
delete ToOptimize;
delete ToNotOptimize;
delete ToOptimizeLoopExtracted;
@@ -339,8 +340,8 @@ static bool ExtractLoops(BugDriver &BD,
// extract another loop.
std::string ErrorMsg;
if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, &ErrorMsg)){
- std::cerr << BD.getToolName() << ": Error linking modules together:"
- << ErrorMsg << '\n';
+ errs() << BD.getToolName() << ": Error linking modules together:"
+ << ErrorMsg << '\n';
exit(1);
}
delete ToOptimizeLoopExtracted;
@@ -462,7 +463,7 @@ static bool ExtractBlocks(BugDriver &BD,
Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract);
if (Extracted == 0) {
// Weird, extraction should have worked.
- std::cerr << "Nondeterministic problem extracting blocks??\n";
+ errs() << "Nondeterministic problem extracting blocks??\n";
delete ProgClone;
delete ToExtract;
return false;
@@ -481,8 +482,8 @@ static bool ExtractBlocks(BugDriver &BD,
std::string ErrorMsg;
if (Linker::LinkModules(ProgClone, Extracted, &ErrorMsg)) {
- std::cerr << BD.getToolName() << ": Error linking modules together:"
- << ErrorMsg << '\n';
+ errs() << BD.getToolName() << ": Error linking modules together:"
+ << ErrorMsg << '\n';
exit(1);
}
delete Extracted;
@@ -606,8 +607,8 @@ bool BugDriver::debugMiscompilation() {
// Make sure something was miscompiled...
if (!BugpointIsInterrupted)
if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
- std::cerr << "*** Optimized program matches reference output! No problem"
- << " detected...\nbugpoint can't help you with your problem!\n";
+ errs() << "*** Optimized program matches reference output! No problem"
+ << " detected...\nbugpoint can't help you with your problem!\n";
return false;
}
@@ -796,7 +797,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
}
if (verifyModule(*Test) || verifyModule(*Safe)) {
- std::cerr << "Bugpoint has a bug, which corrupted a module!!\n";
+ errs() << "Bugpoint has a bug, which corrupted a module!!\n";
abort();
}
}
@@ -813,12 +814,12 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
sys::Path TestModuleBC("bugpoint.test.bc");
std::string ErrMsg;
if (TestModuleBC.makeUnique(true, &ErrMsg)) {
- std::cerr << BD.getToolName() << "Error making unique filename: "
- << ErrMsg << "\n";
+ errs() << BD.getToolName() << "Error making unique filename: "
+ << ErrMsg << "\n";
exit(1);
}
if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) {
- std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
+ errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
delete Test;
@@ -826,13 +827,13 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
// Make the shared library
sys::Path SafeModuleBC("bugpoint.safe.bc");
if (SafeModuleBC.makeUnique(true, &ErrMsg)) {
- std::cerr << BD.getToolName() << "Error making unique filename: "
- << ErrMsg << "\n";
+ errs() << BD.getToolName() << "Error making unique filename: "
+ << ErrMsg << "\n";
exit(1);
}
if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) {
- std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
+ errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
std::string SharedObject = BD.compileSharedObject(SafeModuleBC.toString());
@@ -843,9 +844,9 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
int Result = BD.diffProgram(TestModuleBC.toString(), SharedObject, false);
if (Result)
- std::cerr << ": still failing!\n";
+ errs() << ": still failing!\n";
else
- std::cerr << ": didn't fail.\n";
+ errs() << ": didn't fail.\n";
TestModuleBC.eraseFromDisk();
SafeModuleBC.eraseFromDisk();
sys::Path(SharedObject).eraseFromDisk();
@@ -885,13 +886,13 @@ bool BugDriver::debugCodeGenerator() {
sys::Path TestModuleBC("bugpoint.test.bc");
std::string ErrMsg;
if (TestModuleBC.makeUnique(true, &ErrMsg)) {
- std::cerr << getToolName() << "Error making unique filename: "
- << ErrMsg << "\n";
+ errs() << getToolName() << "Error making unique filename: "
+ << ErrMsg << "\n";
exit(1);
}
if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) {
- std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
+ errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
delete ToCodeGen;
@@ -899,13 +900,13 @@ bool BugDriver::debugCodeGenerator() {
// Make the shared library
sys::Path SafeModuleBC("bugpoint.safe.bc");
if (SafeModuleBC.makeUnique(true, &ErrMsg)) {
- std::cerr << getToolName() << "Error making unique filename: "
- << ErrMsg << "\n";
+ errs() << getToolName() << "Error making unique filename: "
+ << ErrMsg << "\n";
exit(1);
}
if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) {
- std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
+ errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
std::string SharedObject = compileSharedObject(SafeModuleBC.toString());
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 62290f935f..d610676d4d 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -63,10 +63,10 @@ static int RunProgramWithTimeout(const sys::Path &ProgramPath,
redirects[2] = &StdErrFile;
if (0) {
- std::cerr << "RUN:";
+ errs() << "RUN:";
for (unsigned i = 0; Args[i]; ++i)
- std::cerr << " " << Args[i];
- std::cerr << "\n";
+ errs() << " " << Args[i];
+ errs() << "\n";
}
return
@@ -87,7 +87,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) {
sys::Path ErrorFilename("bugpoint.program_error_messages");
std::string ErrMsg;
if (ErrorFilename.makeUnique(true, &ErrMsg)) {
- std::cerr << "Error making unique filename: " << ErrMsg << "\n";
+ errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
@@ -159,10 +159,10 @@ int LLI::ExecuteProgram(const std::string &Bitcode,
LLIArgs.push_back(0);
std::cout << "<lli>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = LLIArgs.size()-1; i != e; ++i)
- std::cerr << " " << LLIArgs[i];
- std::cerr << "\n";
+ errs() << " " << LLIArgs[i];
+ errs() << "\n";
);
return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
@@ -295,7 +295,7 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
sys::Path uniqueFile(Bitcode+".llc.s");
std::string ErrMsg;
if (uniqueFile.makeUnique(true, &ErrMsg)) {
- std::cerr << "Error making unique filename: " << ErrMsg << "\n";
+ errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
OutputAsmFile = uniqueFile;
@@ -313,10 +313,10 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
LLCArgs.push_back (0);
std::cout << "<llc>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
- std::cerr << " " << LLCArgs[i];
- std::cerr << "\n";
+ errs() << " " << LLCArgs[i];
+ errs() << "\n";
);
if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0],
sys::Path(), sys::Path(), sys::Path()))
@@ -369,7 +369,7 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
Message = "Found llc: " + LLCPath + "\n";
GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
if (!gcc) {
- std::cerr << Message << "\n";
+ errs() << Message << "\n";
exit(1);
}
return new LLC(LLCPath, gcc, Args, GCCArgs);
@@ -430,12 +430,12 @@ int JIT::ExecuteProgram(const std::string &Bitcode,
JITArgs.push_back(0);
std::cout << "<jit>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = JITArgs.size()-1; i != e; ++i)
- std::cerr << " " << JITArgs[i];
- std::cerr << "\n";
+ errs() << " " << JITArgs[i];
+ errs() << "\n";
);
- DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
+ DEBUG(errs() << "\nSending output to " << OutputFile << "\n");
return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
Timeout, MemoryLimit);
@@ -460,7 +460,7 @@ GCC::FileType CBE::OutputCode(const std::string &Bitcode,
sys::Path uniqueFile(Bitcode+".cbe.c");
std::string ErrMsg;
if (uniqueFile.makeUnique(true, &ErrMsg)) {
- std::cerr << "Error making unique filename: " << ErrMsg << "\n";
+ errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
OutputCFile = uniqueFile;
@@ -479,10 +479,10 @@ GCC::FileType CBE::OutputCode(const std::string &Bitcode,
LLCArgs.push_back (0);
std::cout << "<cbe>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
- std::cerr << " " << LLCArgs[i];
- std::cerr << "\n";
+ errs() << " " << LLCArgs[i];
+ errs() << "\n";
);
if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(),
sys::Path()))
@@ -533,7 +533,7 @@ CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
Message = "Found llc: " + LLCPath.toString() + "\n";
GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
if (!gcc) {
- std::cerr << Message << "\n";
+ errs() << Message << "\n";
exit(1);
}
return new CBE(LLCPath, gcc, Args);
@@ -599,7 +599,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
sys::Path OutputBinary (ProgramFile+".gcc.exe");
std::string ErrMsg;
if (OutputBinary.makeUnique(true, &ErrMsg)) {
- std::cerr << "Error making unique filename: " << ErrMsg << "\n";
+ errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
@@ -622,10 +622,10 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
GCCArgs.push_back(0); // NULL terminator
std::cout << "<gcc>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = GCCArgs.size()-1; i != e; ++i)
- std::cerr << " " << GCCArgs[i];
- std::cerr << "\n";
+ errs() << " " << GCCArgs[i];
+ errs() << "\n";
);
if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
sys::Path())) {
@@ -666,16 +666,16 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
// Now that we have a binary, run it!
std::cout << "<program>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = ProgramArgs.size()-1; i != e; ++i)
- std::cerr << " " << ProgramArgs[i];
- std::cerr << "\n";
+ errs() << " " << ProgramArgs[i];
+ errs() << "\n";
);
FileRemover OutputBinaryRemover(OutputBinary);
if (RemoteClientPath.isEmpty()) {
- DEBUG(std::cerr << "<run locally>" << std::flush;);
+ DEBUG(errs() << "<run locally>";);
return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
Timeout, MemoryLimit);
@@ -685,8 +685,8 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
&ProgramArgs[0], sys::Path(InputFile), sys::Path(OutputFile),
sys::Path(OutputFile), Timeout, MemoryLimit);
if (RemoteClientStatus != 0) {
- std::cerr << "Remote Client failed with an error: " <<
- RemoteClientStatus << ".\n" << std::flush;
+ errs() << "Remote Client failed with an error: " <<
+ RemoteClientStatus << ".\n";
}
}
@@ -699,7 +699,7 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
sys::Path uniqueFilename(InputFile+LTDL_SHLIB_EXT);
std::string ErrMsg;
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
- std::cerr << "Error making unique filename: " << ErrMsg << "\n";
+ errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
OutputFile = uniqueFilename.toString();
@@ -757,10 +757,10 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
std::cout << "<gcc>" << std::flush;
- DEBUG(std::cerr << "\nAbout to run:\t";
+ DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = GCCArgs.size()-1; i != e; ++i)
- std::cerr << " " << GCCArgs[i];
- std::cerr << "\n";
+ errs() << " " << GCCArgs[i];
+ errs() << "\n";
);
if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
sys::Path())) {
diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp
index 3365b227b1..49e0daee6a 100644
--- a/tools/bugpoint/bugpoint.cpp
+++ b/tools/bugpoint/bugpoint.cpp
@@ -87,20 +87,20 @@ int main(int argc, char **argv) {
try {
return D.run();
} catch (ToolExecutionError &TEE) {
- std::cerr << "Tool execution error: " << TEE.what() << '\n';
+ errs() << "Tool execution error: " << TEE.what() << '\n';
} catch (const std::string& msg) {
- std::cerr << argv[0] << ": " << msg << "\n";
+ errs() << argv[0] << ": " << msg << "\n";
} catch (const std::bad_alloc &e) {
- std::cerr << "Oh no, a bugpoint process ran out of memory!\n"
- "To increase the allocation limits for bugpoint child\n"
- "processes, use the -mlimit option.\n";
+ errs() << "Oh no, a bugpoint process ran out of memory!\n"
+ "To increase the allocation limits for bugpoint child\n"
+ "processes, use the -mlimit option.\n";
} catch (const std::exception &e) {
- std::cerr << "Whoops, a std::exception leaked out of bugpoint: "
- << e.what() << "\n"
- << "This is a bug in bugpoint!\n";
+ errs() << "Whoops, a std::exception leaked out of bugpoint: "
+ << e.what() << "\n"
+ << "This is a bug in bugpoint!\n";
} catch (...) {
- std::cerr << "Whoops, an exception leaked out of bugpoint. "
- << "This is a bug in bugpoint!\n";
+ errs() << "Whoops, an exception leaked out of bugpoint. "
+ << "This is a bug in bugpoint!\n";
}
return 1;
}