summaryrefslogtreecommitdiff
path: root/tools/opt
diff options
context:
space:
mode:
Diffstat (limited to 'tools/opt')
-rw-r--r--tools/opt/NewPMDriver.cpp5
-rw-r--r--tools/opt/NewPMDriver.h10
-rw-r--r--tools/opt/opt.cpp10
3 files changed, 20 insertions, 5 deletions
diff --git a/tools/opt/NewPMDriver.cpp b/tools/opt/NewPMDriver.cpp
index e577995e26..b05da36d28 100644
--- a/tools/opt/NewPMDriver.cpp
+++ b/tools/opt/NewPMDriver.cpp
@@ -23,10 +23,11 @@
#include "llvm/Support/ToolOutputFile.h"
using namespace llvm;
+using namespace opt_tool;
bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
tool_output_file *Out, StringRef PassPipeline,
- bool NoOutput) {
+ OutputKind OK) {
// Before executing passes, print the final values of the LLVM options.
cl::PrintOptionValues();
@@ -40,7 +41,7 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
MPM.run(&M);
// Declare success.
- if (!NoOutput)
+ if (OK != OK_NoOutput)
Out->keep();
return true;
}
diff --git a/tools/opt/NewPMDriver.h b/tools/opt/NewPMDriver.h
index 17ac75be54..2ae1ad5d83 100644
--- a/tools/opt/NewPMDriver.h
+++ b/tools/opt/NewPMDriver.h
@@ -28,6 +28,14 @@ class LLVMContext;
class Module;
class tool_output_file;
+namespace opt_tool {
+enum OutputKind {
+ OK_NoOutput,
+ OK_OutputAssembly,
+ OK_OutputBitcode
+};
+}
+
/// \brief Driver function to run the new pass manager over a module.
///
/// This function only exists factored away from opt.cpp in order to prevent
@@ -36,7 +44,7 @@ class tool_output_file;
/// when the transition finishes.
bool runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
tool_output_file *Out, StringRef PassPipeline,
- bool NoOutput);
+ opt_tool::OutputKind OK);
}
#endif
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 92b63bd830..c4ab342650 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -49,6 +49,7 @@
#include <algorithm>
#include <memory>
using namespace llvm;
+using namespace opt_tool;
// The OptimizationList is automatically populated with registered Passes by the
// PassNameParser.
@@ -670,14 +671,19 @@ int main(int argc, char **argv) {
if (CheckBitcodeOutputToConsole(Out->os(), !Quiet))
NoOutput = true;
- if (PassPipeline.getNumOccurrences() > 0)
+ if (PassPipeline.getNumOccurrences() > 0) {
+ OutputKind OK = OK_NoOutput;
+ if (!NoOutput)
+ OK = OutputAssembly ? OK_OutputAssembly : OK_OutputBitcode;
+
// The user has asked to use the new pass manager and provided a pipeline
// string. Hand off the rest of the functionality to the new code for that
// layer.
return runPassPipeline(argv[0], Context, *M.get(), Out.get(), PassPipeline,
- NoOutput)
+ OK)
? 0
: 1;
+ }
// Create a PassManager to hold and optimize the collection of passes we are
// about to build.