llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-analysis Author: Fangrui Song (MaskRay) <details> <summary>Changes</summary> PassBuilder uses the PipelineTuningOptions' context, else the TargetMachine's, else null, for which LibraryOptionsContext::get<T> returns T::Global. A caller that sets neither, such as llvm-reduce, silently gets the global values. Take the LLVMContext whose library options the pipelines read as the first constructor parameter instead, as StandardInstrumentations does, and remove PipelineTuningOptions::LibraryOptions. LLM-aided --- Patch is 49.52 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/233150.diff 54 Files Affected: - (modified) clang/lib/CodeGen/BackendUtil.cpp (+2-1) - (modified) clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (+1-1) - (modified) flang/lib/Frontend/FrontendActions.cpp (+2-1) - (modified) llvm/docs/NVPTXUsage.md (+1-1) - (modified) llvm/docs/NewPassManager.md (+2-2) - (modified) llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md (+1-1) - (modified) llvm/examples/Kaleidoscope/Chapter4/toy.cpp (+1-1) - (modified) llvm/examples/Kaleidoscope/Chapter5/toy.cpp (+1-1) - (modified) llvm/examples/Kaleidoscope/Chapter6/toy.cpp (+1-1) - (modified) llvm/examples/Kaleidoscope/Chapter7/toy.cpp (+1-1) - (modified) llvm/include/llvm/Passes/PassBuilder.h (+7-11) - (modified) llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h (+1-1) - (modified) llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h (+2-3) - (modified) llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp (+2-2) - (modified) llvm/lib/LTO/LTOBackend.cpp (+1-1) - (modified) llvm/lib/LTO/ThinLTOCodeGenerator.cpp (+1-1) - (modified) llvm/lib/Passes/PassBuilder.cpp (+3-5) - (modified) llvm/lib/Passes/PassBuilderBindings.cpp (+1-1) - (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+8-9) - (modified) llvm/lib/Passes/RunCodeGen.cpp (+3-3) - (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+1-1) - (modified) llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp (+2-2) - (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+2-2) - (modified) llvm/tools/llc/lib/NewPMDriver.cpp (+2-1) - (modified) llvm/tools/llvm-extract/llvm-extract.cpp (+3-3) - (modified) llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp (+6-4) - (modified) llvm/tools/llvm-reduce/ReducerWorkItem.cpp (+1-1) - (modified) llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp (+2-1) - (modified) llvm/tools/opt/NewPMDriver.cpp (+3-3) - (modified) llvm/tools/opt/NewPMDriver.h (+2-1) - (modified) llvm/tools/opt/optdriver.cpp (+1-1) - (modified) llvm/unittests/Analysis/CtxProfAnalysisTest.cpp (+1-1) - (modified) llvm/unittests/Analysis/LastRunTrackingAnalysisTest.cpp (+1-1) - (modified) llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp (+1-1) - (modified) llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp (+1-1) - (modified) llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp (+1-1) - (modified) llvm/unittests/CodeGen/CodeGenTestBase.h (+1-1) - (modified) llvm/unittests/CodeGen/GCMetadata.cpp (+1-1) - (modified) llvm/unittests/CodeGen/PassManagerTest.cpp (+2-2) - (modified) llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp (+10-10) - (modified) llvm/unittests/IR/LibraryOptionsContextTest.cpp (+1-1) - (modified) llvm/unittests/IR/PassBuilderCallbacksTest.cpp (+2-2) - (modified) llvm/unittests/Passes/Plugins/PluginsTest.cpp (+4-3) - (modified) llvm/unittests/Target/DirectX/ResourceBindingAnalysisTests.cpp (+2-2) - (modified) llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp (+1-1) - (modified) llvm/unittests/Target/X86/TernlogTest.cpp (+1-1) - (modified) llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp (+2-3) - (modified) llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp (+2-2) - (modified) llvm/unittests/Transforms/Scalar/LICMTest.cpp (+1-1) - (modified) llvm/unittests/Transforms/Utils/MemTransferLowering.cpp (+2-2) - (modified) mlir/lib/ExecutionEngine/OptUtils.cpp (+1-1) - (modified) offload/plugins-nextgen/common/src/JIT.cpp (+1-1) - (modified) polly/lib/Support/RegisterPasses.cpp (+24-28) - (modified) polly/lib/Transform/ScopInliner.cpp (+3-5) ``````````diff diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 1ffcf7d7f6b0a7..c4a1bb0be3f010 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -943,7 +943,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline( (CodeGenOpts.DebugPassManager || DebugPassStructure), CodeGenOpts.VerifyEach, PrintPassOpts); SI.registerCallbacks(PIC, &MAM); - PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC, CI.getVirtualFileSystemPtr()); + PassBuilder PB(TheModule->getContext(), TM.get(), PTO, PGOOpt, &PIC, + CI.getVirtualFileSystemPtr()); // Handle the assignment tracking feature options. switch (CodeGenOpts.getAssignmentTrackingMode()) { diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp index 1c745bffe00c00..a35f11ab4619e7 100644 --- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp +++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp @@ -94,7 +94,7 @@ static void RunOptimizationPasses(raw_ostream &OS, Module &M, CGSCCAnalysisManager CGAM; ModuleAnalysisManager MAM; - PassBuilder PB; + PassBuilder PB(M.getContext()); PB.registerModuleAnalyses(MAM); PB.registerCGSCCAnalyses(CGAM); diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index 62dd3fb0548636..a80bcaa873d315 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -1032,7 +1032,8 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) { pto.LoopVectorization = opts.VectorizeLoop; pto.SLPVectorization = opts.VectorizeSLP; - llvm::PassBuilder pb(targetMachine, pto, pgoOpt, &pic); + llvm::PassBuilder pb(llvmModule->getContext(), targetMachine, pto, pgoOpt, + &pic); // Register plugin callbacks with PB. for (const std::unique_ptr<llvm::PassPlugin> &plugin : ci.getPassPlugins()) diff --git a/llvm/docs/NVPTXUsage.md b/llvm/docs/NVPTXUsage.md index a752e4c0894c90..bd307702bc0d97 100644 --- a/llvm/docs/NVPTXUsage.md +++ b/llvm/docs/NVPTXUsage.md @@ -4894,7 +4894,7 @@ pass manager: ```c++ std::unique_ptr<TargetMachine> TM = ...; -PassBuilder PB(TM); +PassBuilder PB(Context, TM.get()); ModulePassManager MPM; PB.parsePassPipeline(MPM, ...); ``` diff --git a/llvm/docs/NewPassManager.md b/llvm/docs/NewPassManager.md index 1c264c3eaad6de..f7d50be46c4bb7 100644 --- a/llvm/docs/NewPassManager.md +++ b/llvm/docs/NewPassManager.md @@ -22,7 +22,7 @@ ModuleAnalysisManager MAM; // Take a look at the PassBuilder constructor parameters for more // customization, e.g. specifying a TargetMachine or various debugging // options. -PassBuilder PB; +PassBuilder PB(MyModule.getContext()); // Register all the basic analyses with the managers. PB.registerModuleAnalyses(MAM); @@ -152,7 +152,7 @@ cases, `PassBuilder` exposes callbacks that allow injecting passes into certain parts of the pipeline. For example, ```cpp -PassBuilder PB; +PassBuilder PB(Context); PB.registerPipelineStartEPCallback( [&](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) { MPM.addPass(FooPass()); diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md index 1a833244f9c1a5..018d4f89978bc9 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md @@ -181,7 +181,7 @@ Next, we register the analysis passes used by the transform passes. ```c++ // Register analysis passes used in these transform passes. - PassBuilder PB; + PassBuilder PB(*TheContext); PB.registerModuleAnalyses(*TheMAM); PB.registerFunctionAnalyses(*TheFAM); PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM); diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp index d21cb82d017965..6027f42ba940c2 100644 --- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp @@ -591,7 +591,7 @@ static void InitializeModuleAndManagers() { TheFPM->addPass(SimplifyCFGPass()); // Register analysis passes used in these transform passes. - PassBuilder PB; + PassBuilder PB(*TheContext); PB.registerModuleAnalyses(*TheMAM); PB.registerFunctionAnalyses(*TheFAM); PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM); diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp index 4c6cd258b58786..0a38291660f93d 100644 --- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp @@ -865,7 +865,7 @@ static void InitializeModuleAndManagers() { TheFPM->addPass(SimplifyCFGPass()); // Register analysis passes used in these transform passes. - PassBuilder PB; + PassBuilder PB(*TheContext); PB.registerModuleAnalyses(*TheMAM); PB.registerFunctionAnalyses(*TheFAM); PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM); diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp index 9fc8864a4df1a4..b9565f62b362d8 100644 --- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp @@ -984,7 +984,7 @@ static void InitializeModuleAndManagers() { TheFPM->addPass(SimplifyCFGPass()); // Register analysis passes used in these transform passes. - PassBuilder PB; + PassBuilder PB(*TheContext); PB.registerModuleAnalyses(*TheMAM); PB.registerFunctionAnalyses(*TheFAM); PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM); diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp index 5ebec1799ad4b6..8ac39c8496178b 100644 --- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp @@ -1154,7 +1154,7 @@ static void InitializeModuleAndManagers() { TheFPM->addPass(SimplifyCFGPass()); // Register analysis passes used in these transform passes. - PassBuilder PB; + PassBuilder PB(*TheContext); PB.registerModuleAnalyses(*TheMAM); PB.registerFunctionAnalyses(*TheFAM); PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM); diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h index 2dd74624b424e3..641d33dd24bfc5 100644 --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -34,6 +34,7 @@ namespace llvm { class StringRef; class AAManager; +class LLVMContext; class TargetMachine; class ModuleSummaryIndex; struct PassesOptions; @@ -54,8 +55,6 @@ class PipelineTuningOptions { LLVM_ABI explicit PipelineTuningOptions( const cl::LibraryOptionsContext *LibraryOptions); - const cl::LibraryOptionsContext *LibraryOptions; - /// Tuning option to set loop interleaving on/off, set based on opt level. bool LoopInterleaving; @@ -129,7 +128,7 @@ enum class PrintPipelinePassesFormat { /// of the built-in passes, and those may reference these members during /// construction. class PassBuilder { - const cl::LibraryOptionsContext *LibraryOptions; + LLVMContext &Context; const PassesOptions &Opts; TargetMachine *TM; PipelineTuningOptions PTO; @@ -151,8 +150,10 @@ class PassBuilder { std::vector<PipelineElement> InnerPipeline; }; + /// The pipelines read the library options of \p Context, which must outlive + /// the PassBuilder. LLVM_ABI explicit PassBuilder( - TargetMachine *TM = nullptr, + LLVMContext &Context, TargetMachine *TM = nullptr, PipelineTuningOptions PTO = PipelineTuningOptions(), std::optional<PGOOptions> PGOOpt = std::nullopt, PassInstrumentationCallbacks *PIC = nullptr, @@ -680,19 +681,14 @@ class PassBuilder { std::string ProfileFile, std::string ProfileRemappingFile); + LLVMContext &getContext() const { return Context; } + /// Returns PIC. External libraries can use this to register pass /// instrumentation callbacks. PassInstrumentationCallbacks *getPassInstrumentationCallbacks() const { return PIC; } - /// Returns the library options the pipelines read: the - /// PipelineTuningOptions', else the TargetMachine's, else null for the global - /// values. - const cl::LibraryOptionsContext *getLibraryOptions() const { - return LibraryOptions; - } - /// Returns the virtual file system. IntrusiveRefCntPtr<vfs::FileSystem> getVirtualFileSystemPtr() const { return FS; diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h index 1d4c21d91a9b1f..67155c2e824b65 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h +++ b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h @@ -25,7 +25,7 @@ class PGOCtxProfLoweringPass explicit PGOCtxProfLoweringPass() = default; // True if contextual instrumentation is enabled. LLVM_ABI static bool - isCtxIRPGOInstrEnabled(const cl::LibraryOptionsContext *LibraryOptions); + isCtxIRPGOInstrEnabled(const cl::LibraryOptionsContext &LibraryOptions); LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); }; diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h index af2e5373f1d6de..cb3b22ad489af7 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h +++ b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h @@ -111,10 +111,9 @@ LLVM_ABI void setProfMetadata(Instruction *TI, ArrayRef<uint64_t> EdgeCounts, LLVM_ABI void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count); -/// Return the value of -pgo-instrument-cold-function-only in LibraryOptions, or -/// its global value if null. +/// Return the value of -pgo-instrument-cold-function-only in LibraryOptions. LLVM_ABI bool isPGOInstrumentColdFunctionOnly( - const cl::LibraryOptionsContext *LibraryOptions); + const cl::LibraryOptionsContext &LibraryOptions); } // end namespace llvm diff --git a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp index d2bff139b32353..75c8b49af5c69b 100644 --- a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp +++ b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp @@ -86,7 +86,7 @@ BlockFreqQuery::ResultTy BlockFreqQuery::operator()(Function &F) { DenseSet<StringRef> Calles; SmallVector<std::pair<const BasicBlock *, uint64_t>, 8> BBFreqs; - PassBuilder PB; + PassBuilder PB(F.getContext()); FunctionAnalysisManager FAM; PB.registerFunctionAnalyses(FAM); @@ -233,7 +233,7 @@ SequenceBBQuery::queryCFG(Function &F, const BlockListTy &CallerBlocks) { VisitedBlocksInfoTy VisitedBlocks; BackEdgesInfoTy BackEdgesInfo; - PassBuilder PB; + PassBuilder PB(F.getContext()); FunctionAnalysisManager FAM; PB.registerFunctionAnalyses(FAM); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 5223ad3e3f251f..ed431be770f593 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -297,7 +297,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, StandardInstrumentations SI(Mod.getContext(), Conf.DebugPassManager, Conf.VerifyEach); SI.registerCallbacks(PIC, &MAM); - PassBuilder PB(TM, Conf.PTO, PGOOpt, &PIC); + PassBuilder PB(Mod.getContext(), TM, Conf.PTO, PGOOpt, &PIC); RegisterPassPlugins(Conf, PB); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 710594d360df37..56a6064a56dec2 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -264,7 +264,7 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM, PipelineTuningOptions PTO; PTO.LoopVectorization = true; PTO.SLPVectorization = true; - PassBuilder PB(&TM, PTO, PGOOpt, &PIC); + PassBuilder PB(TheModule.getContext(), &TM, PTO, PGOOpt, &PIC); std::unique_ptr<TargetLibraryInfoImpl> TLII( new TargetLibraryInfoImpl(TM.getTargetTriple(), TM.Options.VecLib)); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index dd77f96f94379c..6004c3ab4073d7 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -566,14 +566,12 @@ static Expected<OptimizationLevel> parseOptLevelParam(StringRef S) { inconvertibleErrorCode()); } -PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO, +PassBuilder::PassBuilder(LLVMContext &Context, TargetMachine *TM, + PipelineTuningOptions PTO, std::optional<PGOOptions> PGOOpt, PassInstrumentationCallbacks *PIC, IntrusiveRefCntPtr<vfs::FileSystem> FS) - : LibraryOptions(PTO.LibraryOptions ? PTO.LibraryOptions - : TM ? TM->Options.MCOptions.LibraryOptions - : nullptr), - Opts(cl::LibraryOptionsContext::get<PassesOptions>(LibraryOptions)), + : Context(Context), Opts(Context.getLibraryOptions().get<PassesOptions>()), TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC), FS(std::move(FS)) { if (TM) TM->registerPassBuilderCallbacks(*this); diff --git a/llvm/lib/Passes/PassBuilderBindings.cpp b/llvm/lib/Passes/PassBuilderBindings.cpp index 933fe89e53a94c..d9f2f887c6467d 100644 --- a/llvm/lib/Passes/PassBuilderBindings.cpp +++ b/llvm/lib/Passes/PassBuilderBindings.cpp @@ -55,7 +55,7 @@ static LLVMErrorRef runPasses(Module *Mod, Function *Fun, const char *Passes, bool VerifyEach = PassOpts->VerifyEach; PassInstrumentationCallbacks PIC; - PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC); + PassBuilder PB(Mod->getContext(), Machine, PassOpts->PTO, std::nullopt, &PIC); LoopAnalysisManager LAM; FunctionAnalysisManager FAM; diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 125c8e442f27b6..42184d87718c4a 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -168,8 +168,7 @@ extern cl::opt<bool> EnableMemProfContextDisambiguation; } // namespace llvm PipelineTuningOptions::PipelineTuningOptions( - const cl::LibraryOptionsContext *LibraryOptions) - : LibraryOptions(LibraryOptions) { + const cl::LibraryOptionsContext *LibraryOptions) { const PassesOptions &Opts = cl::LibraryOptionsContext::get<PassesOptions>(LibraryOptions); LoopInterleaving = true; @@ -1131,8 +1130,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, const bool IsPreLink = !isThinLTOPostLink(Phase); // Enable contextual profiling instrumentation. const bool IsCtxProfGen = - IsPreLink && - PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled(LibraryOptions); + IsPreLink && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled( + Context.getLibraryOptions()); const bool IsPGOPreLink = !IsCtxProfGen && PGOOpt && IsPreLink; const bool IsPGOInstrGen = IsPGOPreLink && PGOOpt->Action == PGOOptions::IRInstr; @@ -1141,19 +1140,19 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, const bool IsMemprofUse = IsPGOPreLink && !PGOOpt->MemoryProfile.empty(); // We don't want to mix pgo ctx gen and pgo gen; we also don't currently // enable ctx profiling from the frontend. - assert(!(IsPGOInstrGen && - PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled(LibraryOptions)) && + assert(!(IsPGOInstrGen && PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled( + Context.getLibraryOptions())) && "Enabling both instrumented PGO and contextual instrumentation is not " "supported."); const bool IsCtxProfUse = !UseCtxProfile.empty() && isThinLTOPreLink(Phase); assert((Opts.instrument_cold_function_only_path.empty() || - isPGOInstrumentColdFunctionOnly(LibraryOptions)) && + isPGOInstrumentColdFunctionOnly(Context.getLibraryOptions())) && "--instrument-cold-function-only-path is provided but " "--pgo-instrument-cold-function-only is not enabled"); const bool IsColdFuncOnlyInstrGen = - isPGOInstrumentColdFunctionOnly(LibraryOptions) && IsPGOPreLink && - !Opts.instrument_cold_function_only_path.empty(); + isPGOInstrumentColdFunctionOnly(Context.getLibraryOptions()) && + IsPGOPreLink && !Opts.instrument_cold_function_only_path.empty(); if (IsPGOInstrGen || IsPGOInstrUse || IsMemprofUse || IsCtxProfGen || IsCtxProfUse || IsColdFuncOnlyInstrGen) diff --git a/llvm/lib/Passes/RunCodeGen.cpp b/llvm/lib/Passes/RunCodeGen.cpp index 7514d6cbb9aca0..bbf451efa48b20 100644 --- a/llvm/lib/Passes/RunCodeGen.cpp +++ b/llvm/lib/Passes/RunCodeGen.cpp @@ -67,9 +67,9 @@ static Error runCodeGenPipelineNewPM(TargetMachine &TM, Module &M, Opt.DisableVerify = DisableVerify; MachineModuleInfo MMI(&TM); PassInstrumentationCallbacks PIC; - PipelineTuningOptions PTOptions(&M.getContext().getLibraryOptions()); - TargetMachine *TMPointer = &TM; - PassBuilder PB(TMPointer, PTOptions, std::nullopt, &PIC, VFS); + const auto &LibraryOptions = M.getContext().getLibraryOptions(); + PipelineTuningOptions PTOptions(&LibraryOptions); + PassBuilder PB(M.getContext(), &TM, PTOptions, std::nullopt, &PIC, VFS); PB.registerModuleAnalyses(MAM); PB.registerCGSCCAnalyses(CGAM); PB.registerFunctionAnalyses(FAM); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 6a5b27e5775c62..53130fae3c9980 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -1283,7 +1283,7 @@ bool AMDGPUTargetMachine::splitModule( CGSCCAnalysisManager CGAM; ModuleAnalysisManager MAM; - PassBuilder PB(this); + PassBuilder PB(M.getContext(), this); PB.registerModuleAnalyses(MAM); PB.registerFunctionAnalyses(FAM); PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); diff --git a/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp b/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp index 5a35c34bc3b29d..74644d67d4260b 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp @@ -31,8 +31,8 @@ using namespace llvm; #define DEBUG_TYPE "ctx-instr-lower" bool PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled( - const cl::LibraryOptionsContext *LibraryOptions) { - return !cl::LibraryOptionsContext::get<InstrumentationOptions>(LibraryOptions) + const cl::LibraryOptionsContext &LibraryOptions) { + return !LibraryOptions.get<InstrumentationOptions>() .profile_context_root.empty(); } diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 2ce082c664eae0..2e45694a374212 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -185,8 +185,8 @@ extern cl::opt<bool> EnableVTableProfileUse; } // namespace llvm bool llvm::isPGOInstrumentColdFunctionOnly( - const cl::LibraryOptionsContext *LibraryOptions) { - return cl::LibraryOptionsContext::get<InstrumentationOptions>(LibraryOptions) + const cl::LibraryOptionsContext &LibraryOptions) { + return LibraryOptions.get<InstrumentationOptions>() .pgo_instrument_cold_function_only; } diff --git a/llvm/tools/llc/lib/NewPMDriver.cpp b/llvm/tools/llc/lib/NewPMDriver.cpp index 156a71c49e0176..03f5afd45c5e86 100644 --- a/llvm/tools/llc/lib/NewPMDriver.cpp +++ b/llvm/tools/llc/lib/NewPMDriver.cpp @@ -143,7 +143,8 @@ int llvm::compileModuleWithNewPM( MAM.registerPass([&] { return MachineModuleAnalysis(MMI); }); - PassBuilder PB(Target.get(), PipelineTuningOptions(), std::nullopt, &PIC); + PassBuilder PB(Context, Target.get(), PipelineTuningOptions(), std::nullopt, + &PIC); for (auto &Pas... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/233150 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
