From a59525786d39de4af8d7ee65531c220348ec48b6 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 12 Jan 2014 12:15:39 +0000 Subject: [PM] Add module and function printing passes for the new pass manager. This implements the legacy passes in terms of the new ones. It adds basic testing using explicit runs of the passes. Next up will be wiring the basic output mechanism of opt up when the new pass manager is engaged unless bitcode writing is requested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199049 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/opt/Passes.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tools/opt') diff --git a/tools/opt/Passes.cpp b/tools/opt/Passes.cpp index 29be9dee94..e79ac422eb 100644 --- a/tools/opt/Passes.cpp +++ b/tools/opt/Passes.cpp @@ -15,7 +15,9 @@ //===----------------------------------------------------------------------===// #include "Passes.h" +#include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Debug.h" using namespace llvm; @@ -39,12 +41,14 @@ struct NoOpFunctionPass { // under different macros. static bool isModulePassName(StringRef Name) { if (Name == "no-op-module") return true; + if (Name == "print") return true; return false; } static bool isFunctionPassName(StringRef Name) { if (Name == "no-op-function") return true; + if (Name == "print") return true; return false; } @@ -54,6 +58,10 @@ static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) { MPM.addPass(NoOpModulePass()); return true; } + if (Name == "print") { + MPM.addPass(PrintModulePass(dbgs())); + return true; + } return false; } @@ -62,6 +70,10 @@ static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) { FPM.addPass(NoOpFunctionPass()); return true; } + if (Name == "print") { + FPM.addPass(PrintFunctionPass(dbgs())); + return true; + } return false; } -- cgit v1.2.3