[llvm] r199071 - [PM] Add an enum for describing the desired output strategy, and run
Chandler Carruth
chandlerc at gmail.com
Sun Jan 12 19:08:41 PST 2014
Author: chandlerc
Date: Sun Jan 12 21:08:40 2014
New Revision: 199071
URL: http://llvm.org/viewvc/llvm-project?rev=199071&view=rev
Log:
[PM] Add an enum for describing the desired output strategy, and run
that through the interface rather than a simple bool. This should allow
starting to wire up real output to round-trip IR through opt with the
new pass manager.
Modified:
llvm/trunk/tools/opt/NewPMDriver.cpp
llvm/trunk/tools/opt/NewPMDriver.h
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/tools/opt/NewPMDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/NewPMDriver.cpp?rev=199071&r1=199070&r2=199071&view=diff
==============================================================================
--- llvm/trunk/tools/opt/NewPMDriver.cpp (original)
+++ llvm/trunk/tools/opt/NewPMDriver.cpp Sun Jan 12 21:08:40 2014
@@ -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 Arg
MPM.run(&M);
// Declare success.
- if (!NoOutput)
+ if (OK != OK_NoOutput)
Out->keep();
return true;
}
Modified: llvm/trunk/tools/opt/NewPMDriver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/NewPMDriver.h?rev=199071&r1=199070&r2=199071&view=diff
==============================================================================
--- llvm/trunk/tools/opt/NewPMDriver.h (original)
+++ llvm/trunk/tools/opt/NewPMDriver.h Sun Jan 12 21:08:40 2014
@@ -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
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=199071&r1=199070&r2=199071&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Sun Jan 12 21:08:40 2014
@@ -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.
More information about the llvm-commits
mailing list