diff --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h b/llvm/include/llvm/Analysis/CGSCCPassManager.h --- a/llvm/include/llvm/Analysis/CGSCCPassManager.h +++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h @@ -161,6 +161,12 @@ (void)AM.template getResult(C, CG); return PreservedAnalyses::all(); } + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName) { + auto ClassName = AnalysisT::name(); + auto PassName = MapClassName2PassName(ClassName); + OS << "require<" << PassName << ">"; + } }; /// A proxy from a \c CGSCCAnalysisManager to a \c Module. @@ -363,6 +369,13 @@ /// Runs the CGSCC pass across every SCC in the module. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName) { + OS << "cgscc("; + Pass->printPipeline(OS, MapClassName2PassName); + OS << ")"; + } + static bool isRequired() { return true; } private: @@ -481,6 +494,13 @@ PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName) { + OS << "function("; + Pass->printPipeline(OS, MapClassName2PassName); + OS << ")"; + } + static bool isRequired() { return true; } private: @@ -528,6 +548,13 @@ PreservedAnalyses run(LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName) { + OS << "devirt<" << MaxIterations << ">("; + Pass->printPipeline(OS, MapClassName2PassName); + OS << ")"; + } + private: std::unique_ptr Pass; int MaxIterations; diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -377,14 +377,15 @@ static_assert(std::is_base_of::value, "Must pass the derived type as the template argument!"); StringRef Name = getTypeName(); - if (Name.startswith("llvm::")) - Name = Name.drop_front(strlen("llvm::")); + Name.consume_front("llvm::"); return Name; } void printPipeline(raw_ostream &OS, function_ref MapClassName2PassName) { - auto ClassName = name(); + StringRef ClassName = name(); + // Drop anonymous namespace here handle passes such as NoOpModulePass. + ClassName.consume_front("(anonymous namespace)::"); auto PassName = MapClassName2PassName(ClassName); OS << PassName; } diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h --- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h +++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h @@ -217,6 +217,12 @@ (void)AM.template getResult(L, AR); return PreservedAnalyses::all(); } + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName) { + auto ClassName = AnalysisT::name(); + auto PassName = MapClassName2PassName(ClassName); + OS << "require<" << PassName << ">"; + } }; /// An alias template to easily name a require analysis loop pass. diff --git a/llvm/test/Other/new-pm-print-pipeline.ll b/llvm/test/Other/new-pm-print-pipeline.ll --- a/llvm/test/Other/new-pm-print-pipeline.ll +++ b/llvm/test/Other/new-pm-print-pipeline.ll @@ -15,3 +15,6 @@ ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-mssa(indvars))' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-4 ; CHECK-4: function(loop-mssa(indvars)) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='cgscc(argpromotion,require,no-op-cgscc,devirt<7>(inline,no-op-cgscc)),function(loop(require))' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-5 +; CHECK-5: cgscc(argpromotion,require,no-op-cgscc,devirt<7>(inline,no-op-cgscc)),function(loop(require))