diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bugpoint/ExtractFunction.cpp | 3 | ||||
-rw-r--r-- | tools/bugpoint/OptimizerDriver.cpp | 6 | ||||
-rw-r--r-- | tools/bugpoint/ToolRunner.cpp | 1 | ||||
-rw-r--r-- | tools/gold/gold-plugin.cpp | 2 | ||||
-rw-r--r-- | tools/llc/llc.cpp | 9 | ||||
-rw-r--r-- | tools/llvm-as/llvm-as.cpp | 5 | ||||
-rw-r--r-- | tools/llvm-dis/llvm-dis.cpp | 5 | ||||
-rw-r--r-- | tools/llvm-extract/llvm-extract.cpp | 12 | ||||
-rw-r--r-- | tools/llvm-ld/llvm-ld.cpp | 7 | ||||
-rw-r--r-- | tools/llvm-link/llvm-link.cpp | 12 | ||||
-rw-r--r-- | tools/llvm-mc/llvm-mc.cpp | 7 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 5 | ||||
-rw-r--r-- | tools/opt/GraphPrinters.cpp | 2 | ||||
-rw-r--r-- | tools/opt/opt.cpp | 7 |
14 files changed, 31 insertions, 52 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 31982e1..a54f51b 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -337,8 +337,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const sys::RemoveFileOnSignal(uniqueFilename); std::string ErrorInfo; - raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Force); + raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(), ErrorInfo); if (!ErrorInfo.empty()) { outs() << "*** Basic Block extraction failed!\n"; errs() << "Error writing list of blocks to not extract: " << ErrorInfo diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 0c9037f..5afb220 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -53,7 +53,7 @@ bool BugDriver::writeProgramToFile(const std::string &Filename, Module *M) const { std::string ErrInfo; raw_fd_ostream Out(Filename.c_str(), ErrInfo, - raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) return true; WriteBitcodeToFile(M ? M : Program, Out); @@ -85,7 +85,7 @@ void BugDriver::EmitProgressBitcode(const std::string &ID, bool NoFlyer) { int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) { std::string ErrInfo; raw_fd_ostream OutFile(ChildOutput.c_str(), ErrInfo, - raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) { errs() << "Error opening bitcode file: " << ChildOutput << "\n"; return 1; @@ -148,7 +148,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes, std::string ErrInfo; raw_fd_ostream InFile(inputFilename.c_str(), ErrInfo, - raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) { diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index f6fc37e..4551d41 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -368,7 +368,6 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode, LLCArgs.push_back ("-o"); LLCArgs.push_back (OutputAsmFile.c_str()); // Output to the Asm file - LLCArgs.push_back ("-f"); // Overwrite as necessary... LLCArgs.push_back (Bitcode.c_str()); // This is the input bitcode LLCArgs.push_back (0); diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 16b3471..6520617 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -364,7 +364,7 @@ ld_plugin_status all_symbols_read_hook(void) { } raw_fd_ostream *objFile = new raw_fd_ostream(uniqueObjPath.c_str(), ErrMsg, - raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrMsg.empty()) { delete objFile; (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 423cf47..c194709 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -55,7 +55,8 @@ InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename")); -static cl::opt<bool> Force("f", cl::desc("Overwrite output files")); +static cl::opt<bool> +Force("f", cl::desc("Enable binary output on terminals")); // Determine optimization level. static cl::opt<char> @@ -139,12 +140,9 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName, std::string error; raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(), error, - (Force ? raw_fd_ostream::F_Force : 0)| raw_fd_ostream::F_Binary); if (!error.empty()) { errs() << error << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; delete FDOut; return 0; } @@ -190,14 +188,11 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName, std::string error; unsigned OpenFlags = 0; - if (Force) OpenFlags |= raw_fd_ostream::F_Force; if (Binary) OpenFlags |= raw_fd_ostream::F_Binary; raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(), error, OpenFlags); if (!error.empty()) { errs() << error << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; delete FDOut; return 0; } diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 487e904..9027cfc 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -38,7 +38,7 @@ OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("filename")); static cl::opt<bool> -Force("f", cl::desc("Overwrite output files")); +Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> DisableOutput("disable-output", cl::desc("Disable output"), cl::init(false)); @@ -98,12 +98,9 @@ int main(int argc, char **argv) { std::string ErrorInfo; std::auto_ptr<raw_ostream> Out (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - (Force?raw_fd_ostream::F_Force : 0) | raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; return 1; } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 2066fff..89073c0 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -38,7 +38,7 @@ OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("filename")); static cl::opt<bool> -Force("f", cl::desc("Overwrite output files")); +Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden); @@ -93,12 +93,9 @@ int main(int argc, char **argv) { std::string ErrorInfo; std::auto_ptr<raw_fd_ostream> Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - (Force?raw_fd_ostream::F_Force : 0) | raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; return 1; } diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 4ea9dd8..543d01f 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/SystemUtils.h" #include "llvm/System/Signals.h" #include <memory> using namespace llvm; @@ -37,7 +38,7 @@ OutputFilename("o", cl::desc("Specify output filename"), cl::value_desc("filename"), cl::init("-")); static cl::opt<bool> -Force("f", cl::desc("Overwrite output files")); +Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> DeleteFn("delete", cl::desc("Delete specified Globals from Module")); @@ -113,16 +114,15 @@ int main(int argc, char **argv) { std::string ErrorInfo; std::auto_ptr<raw_fd_ostream> Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary | - (Force ? raw_fd_ostream::F_Force : 0))); + raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; return 1; } - Passes.add(createBitcodeWriterPass(*Out)); + if (Force || !CheckBitcodeOutputToConsole(*Out, true)) + Passes.add(createBitcodeWriterPass(*Out)); + Passes.run(*M.get()); return 0; diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index 8fcaefd..ef3c250 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -12,7 +12,7 @@ // Additionally, this program outputs a shell script that is used to invoke LLI // to execute the program. In this manner, the generated executable (a.out for // example), is directly executable, whereas the bitcode file actually lives in -// the a.out.bc file generated by this program. Also, Force is on by default. +// the a.out.bc file generated by this program. // // Note that if someone (or a script) deletes the executable program generated, // the .bc file will be left around. Considering that this is a temporary hack, @@ -231,7 +231,7 @@ void GenerateBitcode(Module* M, const std::string& FileName) { // Create the output file. std::string ErrorInfo; raw_fd_ostream Out(FileName.c_str(), ErrorInfo, - raw_fd_ostream::F_Force | raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrorInfo.empty()) PrintAndExit(ErrorInfo); @@ -428,8 +428,7 @@ static void EmitShellScript(char **argv) { // Output the script to start the program... std::string ErrorInfo; - raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo, - llvm::raw_fd_ostream::F_Force); + raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo); if (!ErrorInfo.empty()) PrintAndExit(ErrorInfo); diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 6dc04e6..14327af 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/SystemUtils.h" #include "llvm/System/Signals.h" #include "llvm/System/Path.h" #include <memory> @@ -35,7 +36,8 @@ static cl::opt<std::string> OutputFilename("o", cl::desc("Override output filename"), cl::init("-"), cl::value_desc("filename")); -static cl::opt<bool> Force("f", cl::desc("Overwrite output files")); +static cl::opt<bool> +Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> Verbose("v", cl::desc("Print information about actions taken")); @@ -122,12 +124,9 @@ int main(int argc, char **argv) { std::string ErrorInfo; std::auto_ptr<raw_ostream> Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary | - (Force ? raw_fd_ostream::F_Force : 0))); + raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; return 1; } @@ -142,7 +141,8 @@ int main(int argc, char **argv) { } if (Verbose) errs() << "Writing bitcode...\n"; - WriteBitcodeToFile(Composite.get(), *Out); + if (Force || !CheckBitcodeOutputToConsole(*Out, true)) + WriteBitcodeToFile(Composite.get(), *Out); return 0; } diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index af72fbc..27fb53b 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -53,7 +53,7 @@ FileType("filetype", cl::init(OFT_AssemblyFile), clEnumValEnd)); static cl::opt<bool> -Force("f", cl::desc("Overwrite output files")); +Force("f", cl::desc("Enable binary output on terminals")); static cl::list<std::string> IncludeDirs("I", cl::desc("Directory of include files"), @@ -184,12 +184,9 @@ static formatted_raw_ostream *GetOutputStream() { std::string Err; raw_fd_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), Err, - raw_fd_ostream::F_Binary | - (Force ? raw_fd_ostream::F_Force : 0)); + raw_fd_ostream::F_Binary); if (!Err.empty()) { errs() << Err << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; delete Out; return 0; } diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 4bd754c..37f7786 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -148,7 +148,7 @@ bool LTOCodeGenerator::writeMergedModules(const char *path, // create output file std::string ErrInfo; raw_fd_ostream Out(path, ErrInfo, - raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary); + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) { errMsg = "could not open bitcode file for writing: "; errMsg += path; @@ -179,8 +179,7 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) // generate assembly code bool genResult = false; { - raw_fd_ostream asmFD(uniqueAsmPath.c_str(), errMsg, - raw_fd_ostream::F_Force); + raw_fd_ostream asmFD(uniqueAsmPath.c_str(), errMsg); formatted_raw_ostream asmFile(asmFD); if (!errMsg.empty()) return NULL; diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index c38469c..1ae6be2 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -29,7 +29,7 @@ static void WriteGraphToFile(std::ostream &O, const std::string &GraphName, std::string Filename = GraphName + ".dot"; O << "Writing '" << Filename << "'..."; std::string ErrInfo; - raw_fd_ostream F(Filename.c_str(), ErrInfo, raw_fd_ostream::F_Force); + raw_fd_ostream F(Filename.c_str(), ErrInfo); if (ErrInfo.empty()) WriteGraph(F, GT); diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 7753c21..6effa48 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -55,7 +55,7 @@ OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("filename"), cl::init("-")); static cl::opt<bool> -Force("f", cl::desc("Overwrite output files")); +Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> PrintEachXForm("p", cl::desc("Print module after each transformation")); @@ -367,12 +367,9 @@ int main(int argc, char **argv) { if (OutputFilename != "-") { std::string ErrorInfo; Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary | - (Force ? raw_fd_ostream::F_Force : 0)); + raw_fd_ostream::F_Binary); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; - if (!Force) - errs() << "Use -f command line argument to force output\n"; delete Out; return 1; } |