//
//===----------------------------------------------------------------------===//
-#include "llvm/IR/LLVMContext.h"
+#include "NewPMDriver.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/Verifier.h"
-#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/DebugInfo.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/PrintModulePass.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LinkAllIR.h"
#include "llvm/LinkAllPasses.h"
#include <algorithm>
#include <memory>
using namespace llvm;
+using namespace opt_tool;
// The OptimizationList is automatically populated with registered Passes by the
// PassNameParser.
static cl::list<const PassInfo*, bool, PassNameParser>
PassList(cl::desc("Optimizations available:"));
+// This flag specifies a textual description of the optimization pass pipeline
+// to run over the module. This flag switches opt to use the new pass manager
+// infrastructure, completely disabling all of the flags specific to the old
+// pass management.
+static cl::opt<std::string> PassPipeline(
+ "passes",
+ cl::desc("A textual description of the pass pipeline for optimizing"),
+ cl::Hidden);
+
// Other command line options...
//
static cl::opt<std::string>
if (CheckBitcodeOutputToConsole(Out->os(), !Quiet))
NoOutput = true;
+ 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,
+ OK)
+ ? 0
+ : 1;
+ }
+
// Create a PassManager to hold and optimize the collection of passes we are
// about to build.
//
}
if (PrintEachXForm)
- Passes.add(createPrintModulePass(&errs()));
+ Passes.add(createPrintModulePass(errs()));
}
// If -std-compile-opts was specified at the end of the pass list, add them.
// Write bitcode or assembly to the output as the last step...
if (!NoOutput && !AnalyzeOnly) {
if (OutputAssembly)
- Passes.add(createPrintModulePass(&Out->os()));
+ Passes.add(createPrintModulePass(Out->os()));
else
Passes.add(createBitcodeWriterPass(Out->os()));
}