summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-15 16:35:29 +0000
committerDan Gohman <gohman@apple.com>2009-07-15 16:35:29 +0000
commit65f57c233cd4499e2e8b52a503201e64edfd6a9e (patch)
treeaf96a9f73e7b0060483af26b6f3e1a6210677b67
parent6ca5f9360ce657c1ab382605536751d33c1d138a (diff)
downloadllvm-65f57c233cd4499e2e8b52a503201e64edfd6a9e.tar.gz
llvm-65f57c233cd4499e2e8b52a503201e64edfd6a9e.tar.bz2
llvm-65f57c233cd4499e2e8b52a503201e64edfd6a9e.tar.xz
Use errs() instead of std::cerr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75791 91177308-0d34-0410-b5e6-96231b3b80d8
-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
-rw-r--r--tools/llc/llc.cpp40
-rw-r--r--tools/lli/lli.cpp20
-rw-r--r--tools/llvm-ar/llvm-ar.cpp17
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp112
-rw-r--r--tools/llvm-db/Commands.cpp2
-rw-r--r--tools/llvm-db/llvm-db.cpp4
-rw-r--r--tools/llvm-ld/Optimize.cpp5
-rw-r--r--tools/llvm-nm/llvm-nm.cpp11
-rw-r--r--tools/llvm-prof/llvm-prof.cpp6
-rw-r--r--tools/llvm-ranlib/llvm-ranlib.cpp7
-rw-r--r--tools/opt/AnalysisWrappers.cpp5
20 files changed, 246 insertions, 239 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;
}
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 82dbaba176..346e54706d 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -137,9 +137,9 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
// Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
- std::cerr << ProgName << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
+ errs() << ProgName << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
return 0;
}
// Make sure that the Out file gets unlinked from the disk if we get a
@@ -152,7 +152,7 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
formatted_raw_ostream *Out =
new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
if (!error.empty()) {
- std::cerr << error << '\n';
+ errs() << error << '\n';
delete Out;
return 0;
}
@@ -192,9 +192,9 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
- std::cerr << ProgName << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
+ errs() << ProgName << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
return 0;
}
@@ -208,7 +208,7 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
formatted_raw_ostream *Out =
new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
if (!error.empty()) {
- std::cerr << error << '\n';
+ errs() << error << '\n';
delete Out;
return 0;
}
@@ -237,8 +237,8 @@ int main(int argc, char **argv) {
if (Buffer.get())
M.reset(ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage));
if (M.get() == 0) {
- std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
- std::cerr << "Reason: " << ErrorMessage << "\n";
+ errs() << argv[0] << ": bitcode didn't read correctly.\n";
+ errs() << "Reason: " << ErrorMessage << "\n";
return 1;
}
Module &mod = *M.get();
@@ -256,9 +256,9 @@ int main(int argc, char **argv) {
std::string Err;
TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
if (TheTarget == 0) {
- std::cerr << argv[0] << ": error auto-selecting target for module '"
- << Err << "'. Please use the -march option to explicitly "
- << "pick a target.\n";
+ errs() << argv[0] << ": error auto-selecting target for module '"
+ << Err << "'. Please use the -march option to explicitly "
+ << "pick a target.\n";
return 1;
}
}
@@ -285,7 +285,7 @@ int main(int argc, char **argv) {
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
switch (OptLevel) {
default:
- std::cerr << argv[0] << ": invalid optimization level.\n";
+ errs() << argv[0] << ": invalid optimization level.\n";
return 1;
case ' ': break;
case '0': OLvl = CodeGenOpt::None; break;
@@ -304,8 +304,8 @@ int main(int argc, char **argv) {
// Ask the target to add backend passes as necessary.
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl)) {
- std::cerr << argv[0] << ": target does not support generation of this"
- << " file type!\n";
+ errs() << argv[0] << ": target does not support generation of this"
+ << " file type!\n";
if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
@@ -334,8 +334,8 @@ int main(int argc, char **argv) {
assert(0 && "Invalid file model!");
return 1;
case FileModel::Error:
- std::cerr << argv[0] << ": target does not support generation of this"
- << " file type!\n";
+ errs() << argv[0] << ": target does not support generation of this"
+ << " file type!\n";
if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
@@ -351,8 +351,8 @@ int main(int argc, char **argv) {
}
if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) {
- std::cerr << argv[0] << ": target does not support generation of this"
- << " file type!\n";
+ errs() << argv[0] << ": target does not support generation of this"
+ << " file type!\n";
if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index adf6c1c970..50711e7a2e 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -112,8 +112,8 @@ int main(int argc, char **argv, char * const *envp) {
}
if (!MP) {
- std::cerr << argv[0] << ": error loading program '" << InputFile << "': "
- << ErrorMsg << "\n";
+ errs() << argv[0] << ": error loading program '" << InputFile << "': "
+ << ErrorMsg << "\n";
exit(1);
}
@@ -121,8 +121,8 @@ int main(int argc, char **argv, char * const *envp) {
Module *Mod = NoLazyCompilation
? MP->materializeModule(&ErrorMsg) : MP->getModule();
if (!Mod) {
- std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
- std::cerr << "Reason: " << ErrorMsg << "\n";
+ errs() << argv[0] << ": bitcode didn't read correctly.\n";
+ errs() << "Reason: " << ErrorMsg << "\n";
exit(1);
}
@@ -133,7 +133,7 @@ int main(int argc, char **argv, char * const *envp) {
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
switch (OptLevel) {
default:
- std::cerr << argv[0] << ": invalid optimization level.\n";
+ errs() << argv[0] << ": invalid optimization level.\n";
return 1;
case ' ': break;
case '0': OLvl = CodeGenOpt::None; break;
@@ -149,9 +149,9 @@ int main(int argc, char **argv, char * const *envp) {
EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
if (!EE) {
if (!ErrorMsg.empty())
- std::cerr << argv[0] << ": error creating EE: " << ErrorMsg << "\n";
+ errs() << argv[0] << ": error creating EE: " << ErrorMsg << "\n";
else
- std::cerr << argv[0] << ": unknown error creating EE!\n";
+ errs() << argv[0] << ": unknown error creating EE!\n";
exit(1);
}
@@ -182,7 +182,7 @@ int main(int argc, char **argv, char * const *envp) {
//
Function *EntryFn = Mod->getFunction(EntryFunc);
if (!EntryFn) {
- std::cerr << '\'' << EntryFunc << "\' function not found in module.\n";
+ errs() << '\'' << EntryFunc << "\' function not found in module.\n";
return -1;
}
@@ -219,10 +219,10 @@ int main(int argc, char **argv, char * const *envp) {
ResultGV.IntVal = APInt(32, Result);
Args.push_back(ResultGV);
EE->runFunction(ExitF, Args);
- std::cerr << "ERROR: exit(" << Result << ") returned!\n";
+ errs() << "ERROR: exit(" << Result << ") returned!\n";
abort();
} else {
- std::cerr << "ERROR: exit defined with wrong prototype!\n";
+ errs() << "ERROR: exit defined with wrong prototype!\n";
abort();
}
}
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index fe58db1222..51f00cd9a5 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -18,6 +18,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include <iostream>
#include <algorithm>
@@ -718,15 +719,15 @@ int main(int argc, char **argv) {
if (!ArchivePath.exists()) {
// Produce a warning if we should and we're creating the archive
if (!Create)
- std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
+ errs() << argv[0] << ": creating " << ArchivePath.toString() << "\n";
TheArchive = Archive::CreateEmpty(ArchivePath, Context);
TheArchive->writeToDisk();
} else {
std::string Error;
TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
if (TheArchive == 0) {
- std::cerr << argv[0] << ": error loading '" << ArchivePath << "': "
- << Error << "!\n";
+ errs() << argv[0] << ": error loading '" << ArchivePath << "': "
+ << Error << "!\n";
return 1;
}
}
@@ -749,27 +750,27 @@ int main(int argc, char **argv) {
case DisplayTable: haveError = doDisplayTable(&ErrMsg); break;
case Extract: haveError = doExtract(&ErrMsg); break;
case NoOperation:
- std::cerr << argv[0] << ": No operation was selected.\n";
+ errs() << argv[0] << ": No operation was selected.\n";
break;
}
if (haveError) {
- std::cerr << argv[0] << ": " << ErrMsg << "\n";
+ errs() << argv[0] << ": " << ErrMsg << "\n";
return 1;
}
} catch (const char*msg) {
// These errors are usage errors, thrown only by the various checks in the
// code above.
- std::cerr << argv[0] << ": " << msg << "\n\n";
+ errs() << argv[0] << ": " << msg << "\n\n";
cl::PrintHelpMessage();
exitCode = 1;
} catch (const std::string& msg) {
// These errors are thrown by LLVM libraries (e.g. lib System) and represent
// a more serious error so we bump the exitCode and don't print the usage.
- std::cerr << argv[0] << ": " << msg << "\n";
+ errs() << argv[0] << ": " << msg << "\n";
exitCode = 2;
} catch (...) {
// This really shouldn't happen, but just in case ....
- std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
+ errs() << argv[0] << ": An unexpected unknown exception occurred.\n";
exitCode = 3;
}
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index b401a21ece..fcde8da609 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -289,7 +289,7 @@ static std::map<unsigned, PerBlockIDStats> BlockIDStats;
/// Error - All bitcode analysis errors go through this function, making this a
/// good place to breakpoint if debugging.
static bool Error(const std::string &Err) {
- std::cerr << Err << "\n";
+ errs() << Err << "\n";
return true;
}
@@ -306,7 +306,7 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
// BLOCKINFO is a special part of the stream.
if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
- if (Dump) std::cerr << Indent << "<BLOCKINFO_BLOCK/>\n";
+ if (Dump) errs() << Indent << "<BLOCKINFO_BLOCK/>\n";
if (Stream.ReadBlockInfoBlock())
return Error("Malformed BlockInfoBlock");
uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
@@ -320,17 +320,17 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
const char *BlockName = 0;
if (Dump) {
- std::cerr << Indent << "<";
+ errs() << Indent << "<";
if ((BlockName = GetBlockName(BlockID, *Stream.getBitStreamReader())))
- std::cerr << BlockName;
+ errs() << BlockName;
else
- std::cerr << "UnknownBlock" << BlockID;
+ errs() << "UnknownBlock" << BlockID;
if (NonSymbolic && BlockName)
- std::cerr << " BlockID=" << BlockID;
+ errs() << " BlockID=" << BlockID;
- std::cerr << " NumWords=" << NumWords
- << " BlockCodeSize=" << Stream.GetAbbrevIDWidth() << ">\n";
+ errs() << " NumWords=" << NumWords
+ << " BlockCodeSize=" << Stream.GetAbbrevIDWidth() << ">\n";
}
SmallVector<uint64_t, 64> Record;
@@ -351,11 +351,11 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
BlockStats.NumBits += BlockBitEnd-BlockBitStart;
if (Dump) {
- std::cerr << Indent << "</";
+ errs() << Indent << "</";
if (BlockName)
- std::cerr << BlockName << ">\n";
+ errs() << BlockName << ">\n";
else
- std::cerr << "UnknownBlock" << BlockID << ">\n";
+ errs() << "UnknownBlock" << BlockID << ">\n";
}
return false;
}
@@ -397,25 +397,25 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
BlockStats.CodeFreq[Code].NumAbbrev++;
if (Dump) {
- std::cerr << Indent << " <";
+ errs() << Indent << " <";
if (const char *CodeName =
GetCodeName(Code, BlockID, *Stream.getBitStreamReader()))
- std::cerr << CodeName;
+ errs() << CodeName;
else
- std::cerr << "UnknownCode" << Code;
+ errs() << "UnknownCode" << Code;
if (NonSymbolic &&
GetCodeName(Code, BlockID, *Stream.getBitStreamReader()))
- std::cerr << " codeid=" << Code;
+ errs() << " codeid=" << Code;
if (AbbrevID != bitc::UNABBREV_RECORD)
- std::cerr << " abbrevid=" << AbbrevID;
+ errs() << " abbrevid=" << AbbrevID;
for (unsigned i = 0, e = Record.size(); i != e; ++i)
- std::cerr << " op" << i << "=" << (int64_t)Record[i];
+ errs() << " op" << i << "=" << (int64_t)Record[i];
- std::cerr << "/>";
+ errs() << "/>";
if (BlobStart) {
- std::cerr << " blob data = ";
+ errs() << " blob data = ";
bool BlobIsPrintable = true;
for (unsigned i = 0; i != BlobLen; ++i)
if (!isprint(BlobStart[i])) {
@@ -424,12 +424,12 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
}
if (BlobIsPrintable)
- std::cerr << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'";
+ errs() << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'";
else
- std::cerr << "unprintable, " << BlobLen << " bytes.";
+ errs() << "unprintable, " << BlobLen << " bytes.";
}
- std::cerr << "\n";
+ errs() << "\n";
}
break;
@@ -499,58 +499,58 @@ static int AnalyzeBitcode() {
++NumTopBlocks;
}
- if (Dump) std::cerr << "\n\n";
+ if (Dump) errs() << "\n\n";
uint64_t BufferSizeBits = (EndBufPtr-BufPtr)*CHAR_BIT;
// Print a summary of the read file.
- std::cerr << "Summary of " << InputFilename << ":\n";
- std::cerr << " Total size: ";
+ errs() << "Summary of " << InputFilename << ":\n";
+ errs() << " Total size: ";
PrintSize(BufferSizeBits);
- std::cerr << "\n";
- std::cerr << " Stream type: ";
+ errs() << "\n";
+ errs() << " Stream type: ";
switch (CurStreamType) {
default: assert(0 && "Unknown bitstream type");
- case UnknownBitstream: std::cerr << "unknown\n"; break;
- case LLVMIRBitstream: std::cerr << "LLVM IR\n"; break;
+ case UnknownBitstream: errs() << "unknown\n"; break;
+ case LLVMIRBitstream: errs() << "LLVM IR\n"; break;
}
- std::cerr << " # Toplevel Blocks: " << NumTopBlocks << "\n";
- std::cerr << "\n";
+ errs() << " # Toplevel Blocks: " << NumTopBlocks << "\n";
+ errs() << "\n";
// Emit per-block stats.
- std::cerr << "Per-block Summary:\n";
+ errs() << "Per-block Summary:\n";
for (std::map<unsigned, PerBlockIDStats>::iterator I = BlockIDStats.begin(),
E = BlockIDStats.end(); I != E; ++I) {
- std::cerr << " Block ID #" << I->first;
+ errs() << " Block ID #" << I->first;
if (const char *BlockName = GetBlockName(I->first, StreamFile))
- std::cerr << " (" << BlockName << ")";
- std::cerr << ":\n";
+ errs() << " (" << BlockName << ")";
+ errs() << ":\n";
const PerBlockIDStats &Stats = I->second;
- std::cerr << " Num Instances: " << Stats.NumInstances << "\n";
- std::cerr << " Total Size: ";
+ errs() << " Num Instances: " << Stats.NumInstances << "\n";
+ errs() << " Total Size: ";
PrintSize(Stats.NumBits);
- std::cerr << "\n";
- std::cerr << " % of file: "
- << Stats.NumBits/(double)BufferSizeBits*100 << "\n";
+ errs() << "\n";
+ errs() << " % of file: "
+ << Stats.NumBits/(double)BufferSizeBits*100 << "\n";
if (Stats.NumInstances > 1) {
- std::cerr << " Average Size: ";
+ errs() << " Average Size: ";
PrintSize(Stats.NumBits/(double)Stats.NumInstances);
- std::cerr << "\n";
- std::cerr << " Tot/Avg SubBlocks: " << Stats.NumSubBlocks << "/"
- << Stats.NumSubBlocks/(double)Stats.NumInstances << "\n";
- std::cerr << " Tot/Avg Abbrevs: " << Stats.NumAbbrevs << "/"
- << Stats.NumAbbrevs/(double)Stats.NumInstances << "\n";
- std::cerr << " Tot/Avg Records: " << Stats.NumRecords << "/"
- << Stats.NumRecords/(double)Stats.NumInstances << "\n";
+ errs() << "\n";
+ errs() << " Tot/Avg SubBlocks: " << Stats.NumSubBlocks << "/"
+ << Stats.NumSubBlocks/(double)Stats.NumInstances << "\n";
+ errs() << " Tot/Avg Abbrevs: " << Stats.NumAbbrevs << "/"
+ << Stats.NumAbbrevs/(double)Stats.NumInstances << "\n";
+ errs() << " Tot/Avg Records: " << Stats.NumRecords << "/"
+ << Stats.NumRecords/(double)Stats.NumInstances << "\n";
} else {
- std::cerr << " Num SubBlocks: " << Stats.NumSubBlocks << "\n";
- std::cerr << " Num Abbrevs: " << Stats.NumAbbrevs << "\n";
- std::cerr << " Num Records: " << Stats.NumRecords << "\n";
+ errs() << " Num SubBlocks: " << Stats.NumSubBlocks << "\n";
+ errs() << " Num Abbrevs: " << Stats.NumAbbrevs << "\n";
+ errs() << " Num Records: " << Stats.NumRecords << "\n";
}
if (Stats.NumRecords)
- std::cerr << " % Abbrev Recs: " << (Stats.NumAbbreviatedRecords/
- (double)Stats.NumRecords)*100 << "\n";
- std::cerr << "\n";
+ errs() << " % Abbrev Recs: " << (Stats.NumAbbreviatedRecords/
+ (double)Stats.NumRecords)*100 << "\n";
+ errs() << "\n";
// Print a histogram of the codes we see.
if (!NoHistogram && !Stats.CodeFreq.empty()) {
@@ -561,7 +561,7 @@ static int AnalyzeBitcode() {
std::stable_sort(FreqPairs.begin(), FreqPairs.end());
std::reverse(FreqPairs.begin(), FreqPairs.end());
- std::cerr << "\tRecord Histogram:\n";
+ errs() << "\tRecord Histogram:\n";
fprintf(stderr, "\t\t Count # Bits %% Abv Record Kind\n");
for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) {
const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second];
@@ -581,7 +581,7 @@ static int AnalyzeBitcode() {
else
fprintf(stderr, "UnknownCode%d\n", FreqPairs[i].second);
}
- std::cerr << "\n";
+ errs() << "\n";
}
}
diff --git a/tools/llvm-db/Commands.cpp b/tools/llvm-db/Commands.cpp
index 4c916f4278..bd741a5089 100644
--- a/tools/llvm-db/Commands.cpp
+++ b/tools/llvm-db/Commands.cpp
@@ -500,7 +500,7 @@ void CLIDebugger::breakCommand(std::string &Options) {
if (File == 0)
throw "Unknown file to place breakpoint!";
- std::cerr << "Break: " << File->getFilename() << ":" << LineNo << "\n";
+ errs() << "Break: " << File->getFilename() << ":" << LineNo << "\n";
throw "breakpoints not implemented yet!";
}
diff --git a/tools/llvm-db/llvm-db.cpp b/tools/llvm-db/llvm-db.cpp
index 78dbf71df5..851533e12e 100644
--- a/tools/llvm-db/llvm-db.cpp
+++ b/tools/llvm-db/llvm-db.cpp
@@ -94,9 +94,9 @@ int main(int argc, char **argv, char * const *envp) {
// Now that we have initialized the debugger, run it.
return D.run();
} catch (const std::string& msg) {
- std::cerr << argv[0] << ": " << msg << "\n";
+ errs() << argv[0] << ": " << msg << "\n";
} catch (...) {
- std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+ errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
}
return 1;
}
diff --git a/tools/llvm-ld/Optimize.cpp b/tools/llvm-ld/Optimize.cpp
index e4668958db..7001064659 100644
--- a/tools/llvm-ld/Optimize.cpp
+++ b/tools/llvm-ld/Optimize.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/Verifier.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/StandardPasses.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
@@ -109,8 +110,8 @@ void Optimize(Module* M) {
if (Opt->getNormalCtor())
addPass(Passes, Opt->getNormalCtor()());
else
- std::cerr << "llvm-ld: cannot create pass: " << Opt->getPassName()
- << "\n";
+ errs() << "llvm-ld: cannot create pass: " << Opt->getPassName()
+ << "\n";
}
// The user's passes may leave cruft around. Clean up after them them but
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 4e011807a6..5646835148 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -24,6 +24,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include <algorithm>
#include <cctype>
@@ -147,7 +148,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
if (Result)
DumpSymbolNamesFromModule(Result);
else {
- std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
+ errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
return;
}
@@ -156,17 +157,17 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), Context,
&ErrorMessage);
if (!archive)
- std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
+ errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
std::vector<Module *> Modules;
if (archive->getAllModules(Modules, &ErrorMessage)) {
- std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
+ errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
return;
}
MultipleFiles = true;
std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
} else {
- std::cerr << ToolName << ": " << Filename << ": "
- << "unrecognizable file type\n";
+ errs() << ToolName << ": " << Filename << ": "
+ << "unrecognizable file type\n";
return;
}
}
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index d5dae76e6b..1450444302 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -270,7 +270,7 @@ int main(int argc, char **argv) {
delete Buffer;
}
if (M == 0) {
- std::cerr << argv[0] << ": " << BitcodeFile << ": "
+ errs() << argv[0] << ": " << BitcodeFile << ": "
<< ErrorMessage << "\n";
return 1;
}
@@ -289,9 +289,9 @@ int main(int argc, char **argv) {
return 0;
} catch (const std::string& msg) {
- std::cerr << argv[0] << ": " << msg << "\n";
+ errs() << argv[0] << ": " << msg << "\n";
} catch (...) {
- std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+ errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
}
return 1;
diff --git a/tools/llvm-ranlib/llvm-ranlib.cpp b/tools/llvm-ranlib/llvm-ranlib.cpp
index d9bcc48eb1..a311c52802 100644
--- a/tools/llvm-ranlib/llvm-ranlib.cpp
+++ b/tools/llvm-ranlib/llvm-ranlib.cpp
@@ -17,6 +17,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include <iostream>
#include <iomanip>
@@ -87,13 +88,13 @@ int main(int argc, char **argv) {
printSymbolTable(TheArchive);
} catch (const char* msg) {
- std::cerr << argv[0] << ": " << msg << "\n\n";
+ errs() << argv[0] << ": " << msg << "\n\n";
exitCode = 1;
} catch (const std::string& msg) {
- std::cerr << argv[0] << ": " << msg << "\n";
+ errs() << argv[0] << ": " << msg << "\n";
exitCode = 2;
} catch (...) {
- std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
+ errs() << argv[0] << ": An unexpected unknown exception occurred.\n";
exitCode = 3;
}
return exitCode;
diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp
index 631a0ddbfb..2ab69ea61e 100644
--- a/tools/opt/AnalysisWrappers.cpp
+++ b/tools/opt/AnalysisWrappers.cpp
@@ -21,6 +21,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Analysis/CallGraph.h"
+#include "llvm/Support/raw_ostream.h"
#include <iostream>
using namespace llvm;
@@ -45,10 +46,10 @@ namespace {
E = CS.arg_end(); AI != E; ++AI)
if (isa<Constant>(*AI)) {
if (!PrintedFn) {
- std::cerr << "Function '" << I->getName() << "':\n";
+ errs() << "Function '" << I->getName() << "':\n";
PrintedFn = true;
}
- std::cerr << *User;
+ errs() << *User;
break;
}
}