aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-16 15:30:09 +0000
committerDan Gohman <gohman@apple.com>2009-07-16 15:30:09 +0000
commitac95cc79ac0b899d566cc29c0f646f39c2fa35c0 (patch)
treea56cfb3fae390064970714d26d13dca84545c1fc
parentad60f660c6fd1999a3e21823128d37aca62e9285 (diff)
Convert more tools code from cerr and cout to errs() and outs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76070 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/bugpoint/BugDriver.cpp37
-rw-r--r--tools/bugpoint/BugDriver.h2
-rw-r--r--tools/bugpoint/CrashDebugger.cpp58
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp13
-rw-r--r--tools/bugpoint/ExtractFunction.cpp21
-rw-r--r--tools/bugpoint/FindBugs.cpp33
-rw-r--r--tools/bugpoint/Miscompilation.cpp141
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp49
-rw-r--r--tools/bugpoint/bugpoint.cpp1
-rw-r--r--tools/llvm-as/llvm-as.cpp13
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp2
-rw-r--r--tools/llvm-dis/llvm-dis.cpp11
-rw-r--r--tools/llvm-extract/llvm-extract.cpp8
-rw-r--r--tools/llvm-ld/Optimize.cpp1
-rw-r--r--tools/llvm-ld/llvm-ld.cpp36
-rw-r--r--tools/llvm-link/llvm-link.cpp31
-rw-r--r--tools/llvm-nm/llvm-nm.cpp25
-rw-r--r--tools/llvmc/example/Hello/Hello.cpp5
-rw-r--r--tools/lto/LTOModule.cpp2
-rw-r--r--tools/opt/PrintSCC.cpp24
-rw-r--r--tools/opt/opt.cpp50
21 files changed, 278 insertions, 285 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index ac5de15589..0934206fde 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
-#include <iostream>
#include <memory>
using namespace llvm;
@@ -107,14 +106,14 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
if (Program == 0) return true;
if (!run_as_child)
- std::cout << "Read input file : '" << Filenames[0] << "'\n";
+ outs() << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::auto_ptr<Module> M(ParseInputFile(Filenames[i], Context));
if (M.get() == 0) return true;
if (!run_as_child)
- std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
+ outs() << "Linking in input file: '" << Filenames[i] << "'\n";
std::string ErrorMessage;
if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) {
errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
@@ -128,7 +127,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
}
if (!run_as_child)
- std::cout << "*** All input ok\n";
+ outs() << "*** All input ok\n";
// All input files read successfully!
return false;
@@ -162,7 +161,7 @@ bool BugDriver::run() {
// 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: ";
+ outs() << "Running selected passes on program to test for crash: ";
if (runPasses(PassesToRun))
return debugOptimizerCrash();
}
@@ -171,12 +170,12 @@ bool BugDriver::run() {
if (initializeExecutionEnvironment()) return true;
// Test to see if we have a code generator crash.
- std::cout << "Running the code generator to test for a crash: ";
+ outs() << "Running the code generator to test for a crash: ";
try {
compileProgram(Program);
- std::cout << '\n';
+ outs() << '\n';
} catch (ToolExecutionError &TEE) {
- std::cout << TEE.what();
+ outs() << TEE.what();
return debugCodeGeneratorCrash();
}
@@ -187,7 +186,7 @@ bool BugDriver::run() {
//
bool CreatedOutput = false;
if (ReferenceOutputFile.empty()) {
- std::cout << "Generating reference output from raw program: ";
+ outs() << "Generating reference output from raw program: ";
if(!createReferenceFile(Program)){
return debugCodeGeneratorCrash();
}
@@ -202,10 +201,10 @@ bool BugDriver::run() {
// Diff the output of the raw program against the reference output. If it
// matches, then we assume there is a miscompilation bug and try to
// diagnose it.
- std::cout << "*** Checking the code generator...\n";
+ outs() << "*** Checking the code generator...\n";
try {
if (!diffProgram()) {
- std::cout << "\n*** Output matches: Debugging miscompilation!\n";
+ outs() << "\n*** Output matches: Debugging miscompilation!\n";
return debugMiscompilation();
}
} catch (ToolExecutionError &TEE) {
@@ -213,8 +212,8 @@ bool BugDriver::run() {
return debugCodeGeneratorCrash();
}
- std::cout << "\n*** Input program does not match reference diff!\n";
- std::cout << "Debugging code generator problem!\n";
+ outs() << "\n*** Input program does not match reference diff!\n";
+ outs() << "Debugging code generator problem!\n";
try {
return debugCodeGenerator();
} catch (ToolExecutionError &TEE) {
@@ -227,18 +226,18 @@ void llvm::PrintFunctionList(const std::vector<Function*> &Funcs) {
unsigned NumPrint = Funcs.size();
if (NumPrint > 10) NumPrint = 10;
for (unsigned i = 0; i != NumPrint; ++i)
- std::cout << " " << Funcs[i]->getName();
+ outs() << " " << Funcs[i]->getName();
if (NumPrint < Funcs.size())
- std::cout << "... <" << Funcs.size() << " total>";
- std::cout << std::flush;
+ outs() << "... <" << Funcs.size() << " total>";
+ outs().flush();
}
void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs) {
unsigned NumPrint = GVs.size();
if (NumPrint > 10) NumPrint = 10;
for (unsigned i = 0; i != NumPrint; ++i)
- std::cout << " " << GVs[i]->getName();
+ outs() << " " << GVs[i]->getName();
if (NumPrint < GVs.size())
- std::cout << "... <" << GVs.size() << " total>";
- std::cout << std::flush;
+ outs() << "... <" << GVs.size() << " total>";
+ outs().flush();
}
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index d637c2438b..a46263533c 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -248,7 +248,7 @@ public:
/// optimizations fail for some reason (optimizer crashes), return true,
/// otherwise return false. If DeleteOutput is set to true, the bitcode is
/// deleted on success, and the filename string is undefined. This prints to
- /// cout a single line message indicating whether compilation was successful
+ /// outs() a single line message indicating whether compilation was successful
/// or failed, unless Quiet is set. ExtraArgs specifies additional arguments
/// to pass to the child bugpoint instance.
///
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 34efdc119d..4e73b8f9e9 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -28,8 +28,6 @@
#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;
@@ -65,8 +63,8 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
sys::Path PrefixOutput;
Module *OrigProgram = 0;
if (!Prefix.empty()) {
- std::cout << "Checking to see if these passes crash: "
- << getPassesString(Prefix) << ": ";
+ outs() << "Checking to see if these passes crash: "
+ << getPassesString(Prefix) << ": ";
std::string PfxOutput;
if (BD.runPasses(Prefix, PfxOutput))
return KeepPrefix;
@@ -83,8 +81,8 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
PrefixOutput.eraseFromDisk();
}
- std::cout << "Checking to see if these passes crash: "
- << getPassesString(Suffix) << ": ";
+ outs() << "Checking to see if these passes crash: "
+ << getPassesString(Suffix) << ": ";
if (BD.runPasses(Suffix)) {
delete OrigProgram; // The suffix crashes alone...
@@ -143,9 +141,9 @@ ReduceCrashingGlobalVariables::TestGlobalVariables(
GVSet.insert(CMGV);
}
- std::cout << "Checking for crash with only these global variables: ";
+ outs() << "Checking for crash with only these global variables: ";
PrintGlobalVariableList(GVs);
- std::cout << ": ";
+ outs() << ": ";
// Loop over and delete any global variables which we aren't supposed to be
// playing with...
@@ -217,9 +215,9 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
Functions.insert(CMF);
}
- std::cout << "Checking for crash with only these functions: ";
+ outs() << "Checking for crash with only these functions: ";
PrintFunctionList(Funcs);
- std::cout << ": ";
+ outs() << ": ";
// Loop over and delete any functions which we aren't supposed to be playing
// with...
@@ -277,14 +275,14 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
for (unsigned i = 0, e = BBs.size(); i != e; ++i)
Blocks.insert(cast<BasicBlock>(ValueMap[BBs[i]]));
- std::cout << "Checking for crash with only these blocks:";
+ outs() << "Checking for crash with only these blocks:";
unsigned NumPrint = Blocks.size();
if (NumPrint > 10) NumPrint = 10;
for (unsigned i = 0, e = NumPrint; i != e; ++i)
- std::cout << " " << BBs[i]->getName();
+ outs() << " " << BBs[i]->getName();
if (NumPrint < Blocks.size())
- std::cout << "... <" << Blocks.size() << " total>";
- std::cout << ": ";
+ outs() << "... <" << Blocks.size() << " total>";
+ outs() << ": ";
// Loop over and delete any hack up any blocks that are not listed...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
@@ -382,11 +380,11 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
Instructions.insert(cast<Instruction>(ValueMap[Insts[i]]));
}
- std::cout << "Checking for crash with only " << Instructions.size();
+ outs() << "Checking for crash with only " << Instructions.size();
if (Instructions.size() == 1)
- std::cout << " instruction: ";
+ outs() << " instruction: ";
else
- std::cout << " instructions: ";
+ outs() << " instructions: ";
for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
@@ -445,13 +443,13 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
delete M; // No change made...
} else {
// See if the program still causes a crash...
- std::cout << "\nChecking to see if we can delete global inits: ";
+ outs() << "\nChecking to see if we can delete global inits: ";
if (TestFn(BD, M)) { // Still crashes?
BD.setNewProgram(M);
- std::cout << "\n*** Able to remove all global initializers!\n";
+ outs() << "\n*** Able to remove all global initializers!\n";
} else { // No longer crashes?
- std::cout << " - Removing all global inits hides problem!\n";
+ outs() << " - Removing all global inits hides problem!\n";
delete M;
std::vector<GlobalVariable*> GVs;
@@ -462,7 +460,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
GVs.push_back(I);
if (GVs.size() > 1 && !BugpointIsInterrupted) {
- std::cout << "\n*** Attempting to reduce the number of global "
+ outs() << "\n*** Attempting to reduce the number of global "
<< "variables in the testcase\n";
unsigned OldSize = GVs.size();
@@ -483,7 +481,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
Functions.push_back(I);
if (Functions.size() > 1 && !BugpointIsInterrupted) {
- std::cout << "\n*** Attempting to reduce the number of functions "
+ outs() << "\n*** Attempting to reduce the number of functions "
"in the testcase\n";
unsigned OldSize = Functions.size();
@@ -532,8 +530,8 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
do {
if (BugpointIsInterrupted) break;
--Simplification;
- std::cout << "\n*** Attempting to reduce testcase by deleting instruc"
- << "tions: Simplification Level #" << Simplification << '\n';
+ outs() << "\n*** Attempting to reduce testcase by deleting instruc"
+ << "tions: Simplification Level #" << Simplification << '\n';
// Now that we have deleted the functions that are unnecessary for the
// program, try to remove instructions that are not necessary to cause the
@@ -561,7 +559,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
} else {
if (BugpointIsInterrupted) goto ExitLoops;
- std::cout << "Checking instruction: " << *I;
+ outs() << "Checking instruction: " << *I;
Module *M = BD.deleteInstructionFromProgram(I, Simplification);
// Find out if the pass still crashes on this pass...
@@ -588,7 +586,7 @@ ExitLoops:
// Try to clean up the testcase by running funcresolve and globaldce...
if (!BugpointIsInterrupted) {
- std::cout << "\n*** Attempting to perform final cleanups: ";
+ outs() << "\n*** Attempting to perform final cleanups: ";
Module *M = CloneModule(BD.getProgram());
M = BD.performFinalCleanups(M, true);
@@ -614,15 +612,15 @@ static bool TestForOptimizerCrash(BugDriver &BD, Module *M) {
/// out exactly which pass is crashing.
///
bool BugDriver::debugOptimizerCrash(const std::string &ID) {
- std::cout << "\n*** Debugging optimizer crash!\n";
+ outs() << "\n*** Debugging optimizer crash!\n";
// Reduce the list of passes which causes the optimizer to crash...
if (!BugpointIsInterrupted)
ReducePassList(*this).reduceList(PassesToRun);
- std::cout << "\n*** Found crashing pass"
- << (PassesToRun.size() == 1 ? ": " : "es: ")
- << getPassesString(PassesToRun) << '\n';
+ outs() << "\n*** Found crashing pass"
+ << (PassesToRun.size() == 1 ? ": " : "es: ")
+ << getPassesString(PassesToRun) << '\n';
EmitProgressBitcode(ID);
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index 6e5b7a0514..7fd01ef241 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -19,7 +19,6 @@
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/SystemUtils.h"
#include <fstream>
-#include <iostream>
using namespace llvm;
@@ -126,7 +125,7 @@ namespace {
/// environment for executing LLVM programs.
///
bool BugDriver::initializeExecutionEnvironment() {
- std::cout << "Initializing execution environment: ";
+ outs() << "Initializing execution environment: ";
// Create an instance of the AbstractInterpreter interface as specified on
// the command line
@@ -188,7 +187,7 @@ bool BugDriver::initializeExecutionEnvironment() {
if (!Interpreter)
errs() << Message;
else // Display informational messages on stdout instead of stderr
- std::cout << Message;
+ outs() << Message;
std::string Path = SafeInterpreterPath;
if (Path.empty())
@@ -260,10 +259,10 @@ bool BugDriver::initializeExecutionEnvironment() {
"\"safe\" backend right now!\n";
break;
}
- if (!SafeInterpreter) { std::cout << Message << "\nExiting.\n"; exit(1); }
+ if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); }
gcc = GCC::create(getToolName(), Message, &GCCToolArgv);
- if (!gcc) { std::cout << Message << "\nExiting.\n"; exit(1); }
+ if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); }
// If there was an error creating the selected interpreter, quit with error.
return Interpreter == 0;
@@ -355,7 +354,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
errs() << "<timeout>";
static bool FirstTimeout = true;
if (FirstTimeout) {
- std::cout << "\n"
+ outs() << "\n"
"*** 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"
@@ -418,7 +417,7 @@ bool BugDriver::createReferenceFile(Module *M, const std::string &Filename) {
}
try {
ReferenceOutputFile = executeProgramSafely(Filename);
- std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
+ outs() << "\nReference output is: " << ReferenceOutputFile << "\n\n";
} catch (ToolExecutionError &TEE) {
errs() << TEE.what();
if (Interpreter != SafeInterpreter) {
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 7bdba50791..a939f995cb 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -32,8 +32,6 @@
#include "llvm/System/Path.h"
#include "llvm/System/Signals.h"
#include <set>
-#include <fstream>
-#include <iostream>
using namespace llvm;
namespace llvm {
@@ -145,9 +143,9 @@ Module *BugDriver::ExtractLoop(Module *M) {
Module *NewM = runPassesOn(M, LoopExtractPasses);
if (NewM == 0) {
Module *Old = swapProgramIn(M);
- std::cout << "*** Loop extraction failed: ";
+ outs() << "*** Loop extraction failed: ";
EmitProgressBitcode("loopextraction", true);
- std::cout << "*** Sorry. :( Please report a bug!\n";
+ outs() << "*** Sorry. :( Please report a bug!\n";
swapProgramIn(Old);
return 0;
}
@@ -327,7 +325,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
sys::Path uniqueFilename("bugpoint-extractblocks");
std::string ErrMsg;
if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
- std::cout << "*** Basic Block extraction failed!\n";
+ outs() << "*** Basic Block extraction failed!\n";
errs() << "Error creating temporary file: " << ErrMsg << "\n";
M = swapProgramIn(M);
EmitProgressBitcode("basicblockextractfail", true);
@@ -336,10 +334,13 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
}
sys::RemoveFileOnSignal(uniqueFilename);
- std::ofstream BlocksToNotExtractFile(uniqueFilename.c_str());
- if (!BlocksToNotExtractFile) {
- std::cout << "*** Basic Block extraction failed!\n";
- errs() << "Error writing list of blocks to not extract: " << ErrMsg
+ std::string ErrorInfo;
+ raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(),
+ /*Binary=*/false, /*Force=*/true,
+ ErrorInfo);
+ if (!ErrorInfo.empty()) {
+ outs() << "*** Basic Block extraction failed!\n";
+ errs() << "Error writing list of blocks to not extract: " << ErrorInfo
<< "\n";
M = swapProgramIn(M);
EmitProgressBitcode("basicblockextractfail", true);
@@ -371,7 +372,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
free(ExtraArg);
if (Ret == 0) {
- std::cout << "*** Basic Block extraction failed, please report a bug!\n";
+ outs() << "*** Basic Block extraction failed, please report a bug!\n";
M = swapProgramIn(M);
EmitProgressBitcode("basicblockextractfail", true);
swapProgramIn(M);
diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp
index a28c1b667d..fd1f84b728 100644
--- a/tools/bugpoint/FindBugs.cpp
+++ b/tools/bugpoint/FindBugs.cpp
@@ -19,7 +19,6 @@
#include "llvm/Pass.h"
#include <algorithm>
#include <ctime>
-#include <iostream>
using namespace llvm;
/// runManyPasses - Take the specified pass list and create different
@@ -31,14 +30,14 @@ using namespace llvm;
///
bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses) {
setPassesToRun(AllPasses);
- std::cout << "Starting bug finding procedure...\n\n";
+ outs() << "Starting bug finding procedure...\n\n";
// Creating a reference output if necessary
if (initializeExecutionEnvironment()) return false;
- std::cout << "\n";
+ outs() << "\n";
if (ReferenceOutputFile.empty()) {
- std::cout << "Generating reference output from raw program: \n";
+ outs() << "Generating reference output from raw program: \n";
if (!createReferenceFile(Program))
return false;
}
@@ -55,31 +54,31 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses) {
//
// Step 2: Run optimizer passes on the program and check for success.
//
- std::cout << "Running selected passes on program to test for crash: ";
+ outs() << "Running selected passes on program to test for crash: ";
for(int i = 0, e = PassesToRun.size(); i != e; i++) {
- std::cout << "-" << PassesToRun[i]->getPassArgument( )<< " ";
+ outs() << "-" << PassesToRun[i]->getPassArgument( )<< " ";
}
std::string Filename;
if(runPasses(PassesToRun, Filename, false)) {
- std::cout << "\n";
- std::cout << "Optimizer passes caused failure!\n\n";
+ outs() << "\n";
+ outs() << "Optimizer passes caused failure!\n\n";
debugOptimizerCrash();
return true;
} else {
- std::cout << "Combination " << num << " optimized successfully!\n";
+ outs() << "Combination " << num << " optimized successfully!\n";
}
//
// Step 3: Compile the optimized code.
//
- std::cout << "Running the code generator to test for a crash: ";
+ outs() << "Running the code generator to test for a crash: ";
try {
compileProgram(Program);
- std::cout << '\n';
+ outs() << '\n';
} catch (ToolExecutionError &TEE) {
- std::cout << "\n*** compileProgram threw an exception: ";
- std::cout << TEE.what();
+ outs() << "\n*** compileProgram threw an exception: ";
+ outs() << TEE.what();
return debugCodeGeneratorCrash();
}
@@ -87,14 +86,14 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses) {
// Step 4: Run the program and compare its output to the reference
// output (created above).
//
- std::cout << "*** Checking if passes caused miscompliation:\n";
+ outs() << "*** Checking if passes caused miscompliation:\n";
try {
if (diffProgram(Filename, "", false)) {
- std::cout << "\n*** diffProgram returned true!\n";
+ outs() << "\n*** diffProgram returned true!\n";
debugMiscompilation();
return true;
} else {
- std::cout << "\n*** diff'd output matches!\n";
+ outs() << "\n*** diff'd output matches!\n";
}
} catch (ToolExecutionError &TEE) {
errs() << TEE.what();
@@ -104,7 +103,7 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses) {
sys::Path(Filename).eraseFromDisk();
- std::cout << "\n\n";
+ outs() << "\n\n";
num++;
} //end while
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index efa253823b..83054f30b0 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -26,7 +26,6 @@
#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 {
@@ -57,8 +56,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
std::vector<const PassInfo*> &Suffix) {
// First, run the program with just the Suffix passes. If it is still broken
// with JUST the kept passes, discard the prefix passes.
- std::cout << "Checking to see if '" << getPassesString(Suffix)
- << "' compiles correctly: ";
+ outs() << "Checking to see if '" << getPassesString(Suffix)
+ << "' compiles correctly: ";
std::string BitcodeResult;
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
@@ -71,7 +70,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// Check to see if the finished program matches the reference output...
if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) {
- std::cout << " nope.\n";
+ outs() << " nope.\n";
if (Suffix.empty()) {
errs() << BD.getToolName() << ": I'm confused: the test fails when "
<< "no passes are run, nondeterministic program?\n";
@@ -79,14 +78,14 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
}
return KeepSuffix; // Miscompilation detected!
}
- std::cout << " yup.\n"; // No miscompilation!
+ outs() << " yup.\n"; // No miscompilation!
if (Prefix.empty()) return NoFailure;
// Next, see if the program is broken if we run the "prefix" passes first,
// then separately run the "kept" passes.
- std::cout << "Checking to see if '" << getPassesString(Prefix)
- << "' compiles correctly: ";
+ outs() << "Checking to see if '" << getPassesString(Prefix)
+ << "' compiles correctly: ";
// If it is not broken with the kept passes, it's possible that the prefix
// passes must be run before the kept passes to break it. If the program
@@ -104,11 +103,11 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// If the prefix maintains the predicate by itself, only keep the prefix!
if (BD.diffProgram(BitcodeResult)) {
- std::cout << " nope.\n";
+ outs() << " nope.\n";
sys::Path(BitcodeResult).eraseFromDisk();
return KeepPrefix;
}
- std::cout << " yup.\n"; // No miscompilation!
+ outs() << " yup.\n"; // No miscompilation!
// Ok, so now we know that the prefix passes work, try running the suffix
// passes on the result of the prefix passes.
@@ -125,7 +124,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
if (Suffix.empty())
return NoFailure;
- std::cout << "Checking to see if '" << getPassesString(Suffix)
+ outs() << "Checking to see if '" << getPassesString(Suffix)
<< "' passes compile correctly after the '"
<< getPassesString(Prefix) << "' passes: ";
@@ -140,13 +139,13 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// Run the result...
if (BD.diffProgram(BitcodeResult, "", true/*delete bitcode*/)) {
- std::cout << " nope.\n";
+ outs() << " nope.\n";
delete OriginalInput; // We pruned down the original input...
return KeepSuffix;
}
// Otherwise, we must not be running the bad pass anymore.
- std::cout << " yup.\n"; // No miscompilation!
+ outs() << " yup.\n"; // No miscompilation!
delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test
return NoFailure;
}
@@ -213,12 +212,12 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2,
bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*>&Funcs){
// Test to see if the function is misoptimized if we ONLY run it on the
// functions listed in Funcs.
- std::cout << "Checking to see if the program is misoptimized when "
- << (Funcs.size()==1 ? "this function is" : "these functions are")
- << " run through the pass"
- << (BD.getPassesToRun().size() == 1 ? "" : "es") << ":";
+ outs() << "Checking to see if the program is misoptimized when "
+ << (Funcs.size()==1 ? "this function is" : "these functions are")
+ << " run through the pass"
+ << (BD.getPassesToRun().size() == 1 ? "" : "es") << ":";
PrintFunctionList(Funcs);
- std::cout << '\n';
+ outs() << '\n';
// Split the module into the two halves of the program we want.
DenseMap<const Value*, Value*> ValueMap;
@@ -310,12 +309,12 @@ static bool ExtractLoops(BugDriver &BD,
delete ToOptimize;
BD.switchToInterpreter(AI);
- std::cout << " Testing after loop extraction:\n";
+ outs() << " Testing after loop extraction:\n";
// Clone modules, the tester function will free them.
Module *TOLEBackup = CloneModule(ToOptimizeLoopExtracted);
Module *TNOBackup = CloneModule(ToNotOptimize);
if (!TestFn(BD, ToOptimizeLoopExtracted, ToNotOptimize)) {
- std::cout << "*** Loop extraction masked the problem. Undoing.\n";
+ outs() << "*** Loop extraction masked the problem. Undoing.\n";
// If the program is not still broken, then loop extraction did something
// that masked the error. Stop loop extraction now.
delete TOLEBackup;
@@ -325,7 +324,7 @@ static bool ExtractLoops(BugDriver &BD,
ToOptimizeLoopExtracted = TOLEBackup;
ToNotOptimize = TNOBackup;
- std::cout << "*** Loop extraction successful!\n";
+ outs() << "*** Loop extraction successful!\n";
std::vector<std::pair<std::string, const FunctionType*> > MisCompFunctions;
for (Module::iterator I = ToOptimizeLoopExtracted->begin(),
@@ -394,16 +393,16 @@ namespace {
bool ReduceMiscompiledBlocks::TestFuncs(const std::vector<BasicBlock*> &BBs) {
// Test to see if the function is misoptimized if we ONLY run it on the
// functions listed in Funcs.
- std::cout << "Checking to see if the program is misoptimized when all ";
+ outs() << "Checking to see if the program is misoptimized when all ";
if (!BBs.empty()) {
- std::cout << "but these " << BBs.size() << " blocks are extracted: ";
+ outs() << "but these " << BBs.size() << " blocks are extracted: ";
for (unsigned i = 0, e = BBs.size() < 10 ? BBs.size() : 10; i != e; ++i)
- std::cout << BBs[i]->getName() << " ";
- if (BBs.size() > 10) std::cout << "...";
+ outs() << BBs[i]->getName() << " ";
+ if (BBs.size() > 10) outs() << "...";
} else {
- std::cout << "blocks are extracted.";
+ outs() << "blocks are extracted.";
}
- std::cout << '\n';
+ outs() << '\n';
// Split the module into the two halves of the program we want.
DenseMap<const Value*, Value*> ValueMap;
@@ -526,11 +525,11 @@ DebugAMiscompilation(BugDriver &BD,
if (!BugpointIsInterrupted)
ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions);
- std::cout << "\n*** The following function"
- << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
- << " being miscompiled: ";
+ outs() << "\n*** The following function"
+ << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
+ << " being miscompiled: ";
PrintFunctionList(MiscompiledFunctions);
- std::cout << '\n';
+ outs() << '\n';
// See if we can rip any loops out of the miscompiled functions and still
// trigger the problem.
@@ -549,11 +548,11 @@ DebugAMiscompilation(BugDriver &BD,
if (!BugpointIsInterrupted)
ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions);
- std::cout << "\n*** The following function"
- << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
- << " being miscompiled: ";
+ outs() << "\n*** The following function"
+ << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
+ << " being miscompiled: ";
PrintFunctionList(MiscompiledFunctions);
- std::cout << '\n';
+ outs() << '\n';
}
if (!BugpointIsInterrupted &&
@@ -569,11 +568,11 @@ DebugAMiscompilation(BugDriver &BD,
// Do the reduction...
ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions);
- std::cout << "\n*** The following function"
- << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
- << " being miscompiled: ";
+ outs() << "\n*** The following function"
+ << (MiscompiledFunctions.size() == 1 ? " is" : "s are")