Index: llvm/include/llvm/Analysis/StackLifetime.h =================================================================== --- llvm/include/llvm/Analysis/StackLifetime.h +++ llvm/include/llvm/Analysis/StackLifetime.h @@ -191,6 +191,8 @@ StackLifetimePrinterPass(raw_ostream &OS, StackLifetime::LivenessType Type) : Type(Type), OS(OS) {} PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); }; } // end namespace llvm Index: llvm/include/llvm/Transforms/IPO/LoopExtractor.h =================================================================== --- llvm/include/llvm/Transforms/IPO/LoopExtractor.h +++ llvm/include/llvm/Transforms/IPO/LoopExtractor.h @@ -23,6 +23,8 @@ struct LoopExtractorPass : public PassInfoMixin { LoopExtractorPass(unsigned NumLoops = ~0) : NumLoops(NumLoops) {} PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); private: unsigned NumLoops; Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h =================================================================== --- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h +++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @@ -115,6 +115,8 @@ explicit AddressSanitizerPass(AddressSanitizerOptions Options) : Options(Options){}; PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); static bool isRequired() { return true; } private: Index: llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h =================================================================== --- llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h +++ llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h @@ -39,6 +39,8 @@ : Options(Options){}; PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); static bool isRequired() { return true; } + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); private: HWAddressSanitizerOptions Options; Index: llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h =================================================================== --- llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h +++ llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h @@ -41,6 +41,8 @@ PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); static bool isRequired() { return true; } private: Index: llvm/include/llvm/Transforms/Scalar/EarlyCSE.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/EarlyCSE.h +++ llvm/include/llvm/Transforms/Scalar/EarlyCSE.h @@ -32,6 +32,8 @@ /// Run the pass over the function. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); bool UseMemorySSA; }; Index: llvm/include/llvm/Transforms/Scalar/GVN.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/GVN.h +++ llvm/include/llvm/Transforms/Scalar/GVN.h @@ -126,6 +126,9 @@ /// Run the pass over the function. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); + /// This removes the specified instruction from /// our various maps and marks it for deletion. void markInstructionForDeletion(Instruction *I) { Index: llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h +++ llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h @@ -140,6 +140,8 @@ : UnrollOpts(UnrollOpts) {} PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); }; } // end namespace llvm Index: llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h +++ llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h @@ -23,6 +23,8 @@ public: LowerMatrixIntrinsicsPass(bool Minimal = false) : Minimal(Minimal) {} PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); static bool isRequired() { return true; } }; } // namespace llvm Index: llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h +++ llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h @@ -48,6 +48,8 @@ MergedLoadStoreMotionPass(const MergedLoadStoreMotionOptions &PassOptions) : Options(PassOptions) {} PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); }; } Index: llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h +++ llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h @@ -69,6 +69,9 @@ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U); + + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); }; /// Create the legacy pass object for the simple loop unswitcher. Index: llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h =================================================================== --- llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h +++ llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h @@ -27,6 +27,9 @@ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); + bool PostInlining; static bool isRequired() { return true; } Index: llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h =================================================================== --- llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h +++ llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h @@ -153,6 +153,8 @@ ProfileSummaryInfo *PSI; PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + void printPipeline(raw_ostream &OS, + function_ref MapClassName2PassName); // Shim for old PM. LoopVectorizeResult Index: llvm/lib/Analysis/StackLifetime.cpp =================================================================== --- llvm/lib/Analysis/StackLifetime.cpp +++ llvm/lib/Analysis/StackLifetime.cpp @@ -398,3 +398,19 @@ SL.print(OS); return PreservedAnalyses::all(); } + +void StackLifetimePrinterPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + switch (Type) { + case StackLifetime::LivenessType::May: + OS << "may"; + break; + case StackLifetime::LivenessType::Must: + OS << "must"; + break; + } + OS << ">"; +} Index: llvm/lib/Transforms/IPO/LoopExtractor.cpp =================================================================== --- llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -283,3 +283,13 @@ PA.preserve(); return PA; } + +void LoopExtractorPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (NumLoops == 1) + OS << "single"; + OS << ">"; +} Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1273,6 +1273,16 @@ return PreservedAnalyses::all(); } +void AddressSanitizerPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (Options.CompileKernel) + OS << "kernel"; + OS << ">"; +} + ModuleAddressSanitizerPass::ModuleAddressSanitizerPass( bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator, AsanDtorKind DestructorKind) Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -504,6 +504,17 @@ return PreservedAnalyses::none(); return PreservedAnalyses::all(); } +void HWAddressSanitizerPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (Options.CompileKernel) + OS << "kernel;"; + if (Options.Recover) + OS << "recover"; + OS << ">"; +} void HWAddressSanitizer::createHwasanCtorComdat() { std::tie(HwasanCtorFunction, std::ignore) = Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -681,6 +681,19 @@ return PreservedAnalyses::none(); } +void MemorySanitizerPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (Options.Recover) + OS << "recover;"; + if (Options.Kernel) + OS << "kernel;"; + OS << "track-origins=" << Options.TrackOrigins; + OS << ">"; +} + char MemorySanitizerLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(MemorySanitizerLegacyPass, "msan", Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp =================================================================== --- llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -1642,6 +1642,16 @@ return PA; } +void EarlyCSEPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (UseMemorySSA) + OS << "memssa"; + OS << ">"; +} + namespace { /// A simple and fast domtree-based CSE pass. Index: llvm/lib/Transforms/Scalar/GVN.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVN.cpp +++ llvm/lib/Transforms/Scalar/GVN.cpp @@ -684,6 +684,24 @@ return PA; } +void GVN::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline(OS, + MapClassName2PassName); + + OS << "<"; + if (Options.AllowPRE != None) + OS << (Options.AllowPRE.getValue() ? "" : "no-") << "pre;"; + if (Options.AllowLoadPRE != None) + OS << (Options.AllowLoadPRE.getValue() ? "" : "no-") << "load-pre;"; + if (Options.AllowLoadPRESplitBackedge != None) + OS << (Options.AllowLoadPRESplitBackedge.getValue() ? "" : "no-") + << "split-backedge-load-pre;"; + if (Options.AllowMemDep != None) + OS << (Options.AllowMemDep.getValue() ? "" : "no-") << "memdep"; + OS << ">"; +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void GVN::dump(DenseMap& d) const { errs() << "{\n"; Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -1617,3 +1617,25 @@ return getLoopPassPreservedAnalyses(); } + +void LoopUnrollPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (UnrollOpts.AllowPartial != None) + OS << (UnrollOpts.AllowPartial.getValue() ? "" : "no-") << "partial;"; + if (UnrollOpts.AllowPeeling != None) + OS << (UnrollOpts.AllowPeeling.getValue() ? "" : "no-") << "peeling;"; + if (UnrollOpts.AllowRuntime != None) + OS << (UnrollOpts.AllowRuntime.getValue() ? "" : "no-") << "runtime;"; + if (UnrollOpts.AllowUpperBound != None) + OS << (UnrollOpts.AllowUpperBound.getValue() ? "" : "no-") << "upperbound;"; + if (UnrollOpts.AllowProfileBasedPeeling != None) + OS << (UnrollOpts.AllowProfileBasedPeeling.getValue() ? "" : "no-") + << "profile-peeling;"; + if (UnrollOpts.FullUnrollMaxCount != None) + OS << "full-unroll-max=" << UnrollOpts.FullUnrollMaxCount << ";"; + OS << "O" << UnrollOpts.OptLevel; + OS << ">"; +} Index: llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -2263,6 +2263,16 @@ return PreservedAnalyses::all(); } +void LowerMatrixIntrinsicsPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + if (Minimal) + OS << "minimal"; + OS << ">"; +} + namespace { class LowerMatrixIntrinsicsLegacyPass : public FunctionPass { Index: llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp =================================================================== --- llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -420,3 +420,12 @@ PA.preserveSet(); return PA; } + +void MergedLoadStoreMotionPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + OS << "<"; + OS << (Options.SplitFooterBB ? "" : "no-") << "split-footer-bb"; + OS << ">"; +} Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp =================================================================== --- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -3121,6 +3121,17 @@ return PA; } +void SimpleLoopUnswitchPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + + OS << "<"; + OS << (NonTrivial ? "" : "no-") << "nontrivial;"; + OS << (Trivial ? "" : "no-") << "trivial"; + OS << ">"; +} + namespace { class SimpleLoopUnswitchLegacyPass : public LoopPass { Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp =================================================================== --- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp +++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp @@ -183,3 +183,13 @@ PA.preserveSet(); return PA; } + +void llvm::EntryExitInstrumenterPass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this) + ->printPipeline(OS, MapClassName2PassName); + OS << "<"; + if (PostInlining) + OS << "post-inline"; + OS << ">"; +} Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -10584,3 +10584,14 @@ PA.preserveSet(); return PA; } + +void LoopVectorizePass::printPipeline( + raw_ostream &OS, function_ref MapClassName2PassName) { + static_cast *>(this)->printPipeline( + OS, MapClassName2PassName); + + OS << "<"; + OS << (InterleaveOnlyWhenForced ? "" : "no-") << "interleave-forced-only;"; + OS << (VectorizeOnlyWhenForced ? "" : "no-") << "vectorize-forced-only;"; + OS << ">"; +} Index: llvm/test/Other/new-pm-print-pipeline.ll =================================================================== --- llvm/test/Other/new-pm-print-pipeline.ll +++ llvm/test/Other/new-pm-print-pipeline.ll @@ -16,5 +16,48 @@ ; 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)) +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-vectorize,loop-vectorize)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-5 +; CHECK-5: function(loop-vectorize,loop-vectorize) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(ee-instrument<>,ee-instrument)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-6 +; CHECK-6: function(ee-instrument<>,ee-instrument) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='loop(simple-loop-unswitch,simple-loop-unswitch)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-7 +; CHECK-7: function(loop(simple-loop-unswitch,simple-loop-unswitch)) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(mldst-motion,mldst-motion)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-8 +; CHECK-8: function(mldst-motion,mldst-motion) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(lower-matrix-intrinsics<>,lower-matrix-intrinsics)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-9 +; CHECK-9: function(lower-matrix-intrinsics<>,lower-matrix-intrinsics) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-unroll<>,loop-unroll,loop-unroll)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-10 +; CHECK-10: function(loop-unroll,loop-unroll,loop-unroll) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(gvn<>,gvn,gvn)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-11 +; CHECK-11: function(gvn<>,gvn,gvn) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(early-cse<>,early-cse)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-12 +; CHECK-12: function(early-cse<>,early-cse) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(msan<>,msan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-13 +;;; XXX: msan-module? this is one of the places where the ClassName to pass-name mapping fails. +; CHECK-13: function(msan-module,msan-module) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14 +; CHECK-14: hwasan<>,hwasan + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15 +; CHECK-15: function(asan<>,asan) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16 +; CHECK-16: loop-extract<>,loop-extract + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(print,print)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-17 +; CHECK-17: function(print,print) + +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(simplifycfg,simplifycfg)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-18 +; CHECK-18: function(simplifycfg,simplifycfg) + +; 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-19 +; CHECK-19: cgscc(argpromotion,require,no-op-cgscc,devirt<7>(inline,no-op-cgscc)),function(loop(require))