diff --git a/llvm/include/llvm/Analysis/StackLifetime.h b/llvm/include/llvm/Analysis/StackLifetime.h --- a/llvm/include/llvm/Analysis/StackLifetime.h +++ b/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 diff --git a/llvm/include/llvm/Transforms/IPO/LoopExtractor.h b/llvm/include/llvm/Transforms/IPO/LoopExtractor.h --- a/llvm/include/llvm/Transforms/IPO/LoopExtractor.h +++ b/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; diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h --- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h +++ b/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: diff --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h --- a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h +++ b/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; diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h --- a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h +++ b/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: diff --git a/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h b/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h --- a/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h +++ b/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; }; diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/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) { diff --git a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h b/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h --- a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h +++ b/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 diff --git a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h b/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h --- a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h +++ b/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 diff --git a/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h b/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h --- a/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h +++ b/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); }; } diff --git a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h b/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h --- a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h +++ b/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. diff --git a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h b/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h --- a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h +++ b/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; } diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h --- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h +++ b/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 diff --git a/llvm/lib/Analysis/StackLifetime.cpp b/llvm/lib/Analysis/StackLifetime.cpp --- a/llvm/lib/Analysis/StackLifetime.cpp +++ b/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 << ">"; +} diff --git a/llvm/lib/Transforms/IPO/LoopExtractor.cpp b/llvm/lib/Transforms/IPO/LoopExtractor.cpp --- a/llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ b/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 << ">"; +} diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/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) diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/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) = diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/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", diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/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. diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/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 ? "" : "no-") << "pre;"; + if (Options.AllowLoadPRE != None) + OS << (Options.AllowLoadPRE ? "" : "no-") << "load-pre;"; + if (Options.AllowLoadPRESplitBackedge != None) + OS << (Options.AllowLoadPRESplitBackedge ? "" : "no-") + << "split-backedge-load-pre;"; + if (Options.AllowMemDep != None) + OS << (Options.AllowMemDep ? "" : "no-") << "memdep"; + OS << ">"; +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void GVN::dump(DenseMap& d) const { errs() << "{\n"; diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/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 ? "" : "no-") << "partial;"; + if (UnrollOpts.AllowPeeling != None) + OS << (UnrollOpts.AllowPeeling ? "" : "no-") << "peeling;"; + if (UnrollOpts.AllowRuntime != None) + OS << (UnrollOpts.AllowRuntime ? "" : "no-") << "runtime;"; + if (UnrollOpts.AllowUpperBound != None) + OS << (UnrollOpts.AllowUpperBound ? "" : "no-") << "upperbound;"; + if (UnrollOpts.AllowProfileBasedPeeling != None) + OS << (UnrollOpts.AllowProfileBasedPeeling ? "" : "no-") + << "profile-peeling;"; + if (UnrollOpts.FullUnrollMaxCount != None) + OS << "full-unroll-max=" << UnrollOpts.FullUnrollMaxCount << ";"; + OS << "O" << UnrollOpts.OptLevel; + OS << ">"; +} diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp --- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -2264,6 +2264,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 { diff --git a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp --- a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ b/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 << ">"; +} diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/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 { diff --git a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp --- a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp +++ b/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 << ">"; +} diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -10587,3 +10587,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-") << "vectorized-forced-only;"; + OS << ">"; +}