diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-14 21:44:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-14 21:44:34 +0000 |
commit | f6074ed9f60f23ee721f14e9482816af6aceb931 (patch) | |
tree | fc6b96c68f9677aa5a03d9fcfe28884071f3e205 /llvm/tools/bugpoint/OptimizerDriver.cpp | |
parent | d702241c98315bd0271b21108a49b56b5b25cbe5 (diff) | |
download | bcm5719-llvm-f6074ed9f60f23ee721f14e9482816af6aceb931.tar.gz bcm5719-llvm-f6074ed9f60f23ee721f14e9482816af6aceb931.zip |
Change the BugDriver to store the current module with std::unique_ptr.
While there, change a bunch of helper functions to take references to
avoid adding calls to get().
This should conclude the bugpoint yak shaving.
llvm-svn: 325177
Diffstat (limited to 'llvm/tools/bugpoint/OptimizerDriver.cpp')
-rw-r--r-- | llvm/tools/bugpoint/OptimizerDriver.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index f4acce421b3..34f447831d0 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -48,11 +48,10 @@ static cl::opt<std::string> cl::desc("Path to opt. (default: search path " "for 'opt'.)")); -/// writeProgramToFile - This writes the current "Program" to the named bitcode -/// file. If an error occurs, true is returned. -/// -static bool writeProgramToFileAux(ToolOutputFile &Out, const Module *M) { - WriteBitcodeToFile(*M, Out.os(), PreserveBitcodeUseListOrder); +/// This writes the current "Program" to the named bitcode file. If an error +/// occurs, true is returned. +static bool writeProgramToFileAux(ToolOutputFile &Out, const Module &M) { + WriteBitcodeToFile(M, Out.os(), PreserveBitcodeUseListOrder); Out.os().close(); if (!Out.os().has_error()) { Out.keep(); @@ -62,14 +61,14 @@ static bool writeProgramToFileAux(ToolOutputFile &Out, const Module *M) { } bool BugDriver::writeProgramToFile(const std::string &Filename, int FD, - const Module *M) const { + const Module &M) const { ToolOutputFile Out(Filename, FD); return writeProgramToFileAux(Out, M); } -bool BugDriver::writeProgramToFile(int FD, const Module *M) const { +bool BugDriver::writeProgramToFile(int FD, const Module &M) const { raw_fd_ostream OS(FD, /*shouldClose*/ false); - WriteBitcodeToFile(*M, OS, PreserveBitcodeUseListOrder); + WriteBitcodeToFile(M, OS, PreserveBitcodeUseListOrder); OS.flush(); if (!OS.has_error()) return false; @@ -78,7 +77,7 @@ bool BugDriver::writeProgramToFile(int FD, const Module *M) const { } bool BugDriver::writeProgramToFile(const std::string &Filename, - const Module *M) const { + const Module &M) const { std::error_code EC; ToolOutputFile Out(Filename, EC, sys::fs::F_None); if (!EC) @@ -86,10 +85,9 @@ bool BugDriver::writeProgramToFile(const std::string &Filename, return true; } -/// EmitProgressBitcode - This function is used to output the current Program -/// to a file named "bugpoint-ID.bc". -/// -void BugDriver::EmitProgressBitcode(const Module *M, const std::string &ID, +/// This function is used to output the current Program to a file named +/// "bugpoint-ID.bc". +void BugDriver::EmitProgressBitcode(const Module &M, const std::string &ID, bool NoFlyer) const { // Output the input to the current pass to a bitcode file, emit a message // telling the user how to reproduce it: opt -foo blah.bc @@ -129,7 +127,7 @@ static cl::list<std::string> OptArgs("opt-args", cl::Positional, /// outs() a single line message indicating whether compilation was successful /// or failed. /// -bool BugDriver::runPasses(Module *Program, +bool BugDriver::runPasses(Module &Program, const std::vector<std::string> &Passes, std::string &OutputFilename, bool DeleteOutput, bool Quiet, unsigned NumExtraArgs, @@ -158,7 +156,7 @@ bool BugDriver::runPasses(Module *Program, DiscardTemp Discard{*Temp}; raw_fd_ostream OS(Temp->FD, /*shouldClose*/ false); - WriteBitcodeToFile(*Program, OS, PreserveBitcodeUseListOrder); + WriteBitcodeToFile(Program, OS, PreserveBitcodeUseListOrder); OS.flush(); if (OS.has_error()) { errs() << "Error writing bitcode file: " << Temp->TmpName << "\n"; @@ -272,7 +270,7 @@ std::unique_ptr<Module> BugDriver::runPassesOn(Module *M, const std::vector<std::string> &Passes, unsigned NumExtraArgs, const char *const *ExtraArgs) { std::string BitcodeResult; - if (runPasses(M, Passes, BitcodeResult, false /*delete*/, true /*quiet*/, + if (runPasses(*M, Passes, BitcodeResult, false /*delete*/, true /*quiet*/, NumExtraArgs, ExtraArgs)) { return nullptr; } |