[Mlir-commits] [clang] [flang] [lld] [llvm] [mlir] [Passes] Make PipelineTuningOptions not read library options (PR #238434)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 3 08:50:32 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
PR #<!-- -->232599 added `PipelineTuningOptions(const cl::LibraryOptionsContext
*);` for per-context library option support. The default ctor passes a
null context, so it and the getters it calls (e.g.
getForgetSCEVInLoopUnroll) read `T::Global` instead of the values parsed
into an LLVMContext.
Make the members whose defaults come from library options std::optional.
PassBuilder sets the unset ones from its LLVMContext. Remove the pointer
parameter ctor from #<!-- -->232599.
LLVMRunPasses now reads these options from the module's context, like
the other PassBuilder options.
LLM-aided
---
Patch is 37.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/238434.diff
27 Files Affected:
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+1-2)
- (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (-1)
- (modified) flang/lib/Frontend/FrontendActions.cpp (+1-1)
- (modified) lld/COFF/LTO.cpp (-1)
- (modified) lld/ELF/LTO.cpp (-1)
- (modified) lld/MachO/LTO.cpp (-1)
- (modified) lld/wasm/LTO.cpp (-1)
- (modified) llvm/include/llvm/Analysis/CallGraphSCCPass.h (+1-1)
- (modified) llvm/include/llvm/Passes/PassBuilder.h (+21-28)
- (modified) llvm/include/llvm/Transforms/Scalar/LICM.h (+4-6)
- (modified) llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h (+2-3)
- (modified) llvm/lib/Analysis/CallGraphSCCPass.cpp (+2-3)
- (modified) llvm/lib/DTLTO/CMakeLists.txt (+1)
- (modified) llvm/lib/DTLTO/DTLTO.cpp (+4-1)
- (modified) llvm/lib/LTO/LTOCodeGenerator.cpp (-1)
- (modified) llvm/lib/LTO/ThinLTOCodeGenerator.cpp (+1-1)
- (modified) llvm/lib/Passes/PassBuilder.cpp (+2-1)
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+58-50)
- (modified) llvm/lib/Passes/RunCodeGen.cpp (+1-2)
- (modified) llvm/lib/Transforms/Scalar/LICM.cpp (+4-6)
- (modified) llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp (+2-3)
- (modified) llvm/tools/gold/gold-plugin.cpp (-1)
- (modified) llvm/tools/llvm-lto2/llvm-lto2.cpp (-1)
- (modified) llvm/tools/opt/NewPMDriver.cpp (+1-1)
- (modified) llvm/utils/gn/secondary/llvm/lib/DTLTO/BUILD.gn (+1)
- (modified) mlir/lib/ExecutionEngine/OptUtils.cpp (+1-1)
- (modified) utils/bazel/llvm-project-overlay/llvm/BUILD.bazel (+1)
``````````diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index e04934548176f8..f226878f64f6f8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -910,7 +910,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (TM)
TM->setPGOOption(PGOOpt);
- PipelineTuningOptions PTO(&LibraryOptions);
+ PipelineTuningOptions PTO;
PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
PTO.LoopInterchange = CodeGenOpts.InterchangeLoops;
PTO.LoopFusion = CodeGenOpts.FuseLoops;
@@ -1387,7 +1387,6 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex,
Conf.SampleProfile = std::move(SampleProfile);
const cl::LibraryOptionsContext &LibraryOptions =
M->getContext().getLibraryOptions();
- Conf.PTO = PipelineTuningOptions(&LibraryOptions);
Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops;
Conf.PTO.LoopInterchange = CGOpts.InterchangeLoops;
Conf.PTO.LoopFusion = CGOpts.FuseLoops;
diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
index 6550902a6a6551..7bd9b007c74087 100644
--- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
+++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
@@ -376,7 +376,6 @@ createLTO(const cl::LibraryOptionsContext &LibraryOptions,
const llvm::Triple Triple("nvptx64-nvidia-cuda");
lto::Config Conf;
Conf.LibraryOptions = &LibraryOptions;
- Conf.PTO = PipelineTuningOptions(&LibraryOptions);
lto::ThinBackend Backend;
unsigned Jobs = 0;
if (auto *Arg = Args.getLastArg(OPT_jobs))
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 823b437d6e83fc..12047a65fb423f 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -966,7 +966,7 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
llvm::PassInstrumentationCallbacks pic;
const llvm::cl::LibraryOptionsContext &libraryOptions =
llvmModule->getContext().getLibraryOptions();
- llvm::PipelineTuningOptions pto(&libraryOptions);
+ llvm::PipelineTuningOptions pto;
std::optional<llvm::PGOOptions> pgoOpt;
if (opts.hasProfileIRInstr()) {
diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index 20209019a3e6fe..ed22a2f8206395 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -57,7 +57,6 @@ std::string BitcodeCompiler::getThinLTOOutputFile(StringRef path) {
lto::Config BitcodeCompiler::createConfig() {
lto::Config c;
c.LibraryOptions = &ctx.config.libraryOptions;
- c.PTO = PipelineTuningOptions(c.LibraryOptions);
c.Options = initTargetOptionsFromCodeGenFlags();
c.Options.EmitAddrsig = true;
for (StringRef C : ctx.config.mllvmOpts)
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 0fa5673ed0f25b..7666e2bbb84094 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -56,7 +56,6 @@ static std::string getThinLTOOutputFile(Ctx &ctx, StringRef modulePath) {
static lto::Config createConfig(Ctx &ctx) {
lto::Config c;
c.LibraryOptions = &ctx.arg.libraryOptions;
- c.PTO = PipelineTuningOptions(c.LibraryOptions);
// LLD supports the new relocations and address-significance tables.
c.Options = initTargetOptionsFromCodeGenFlags();
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 8eb008c990fe6c..d54a74e108e05f 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -39,7 +39,6 @@ static std::string getThinLTOOutputFile(StringRef modulePath) {
static lto::Config createConfig() {
lto::Config c;
c.LibraryOptions = &config->libraryOptions;
- c.PTO = PipelineTuningOptions(c.LibraryOptions);
c.Options = initTargetOptionsFromCodeGenFlags();
c.Options.EmitAddrsig = config->icfLevel == ICFLevel::safe ||
config->icfLevel == ICFLevel::safe_thunks;
diff --git a/lld/wasm/LTO.cpp b/lld/wasm/LTO.cpp
index 8bafd95a258688..774908babc84de 100644
--- a/lld/wasm/LTO.cpp
+++ b/lld/wasm/LTO.cpp
@@ -43,7 +43,6 @@ static std::string getThinLTOOutputFile(StringRef modulePath) {
static lto::Config createConfig() {
lto::Config c;
c.LibraryOptions = &ctx.arg.libraryOptions;
- c.PTO = PipelineTuningOptions(c.LibraryOptions);
c.Options = initTargetOptionsFromCodeGenFlags();
// Always emit a section per function/data with LTO.
diff --git a/llvm/include/llvm/Analysis/CallGraphSCCPass.h b/llvm/include/llvm/Analysis/CallGraphSCCPass.h
index a9042a43fec700..68c0277e9fb63d 100644
--- a/llvm/include/llvm/Analysis/CallGraphSCCPass.h
+++ b/llvm/include/llvm/Analysis/CallGraphSCCPass.h
@@ -35,7 +35,7 @@ namespace cl {
class LibraryOptionsContext;
} // namespace cl
-LLVM_ABI unsigned getMaxDevirtIterations(const cl::LibraryOptionsContext *);
+LLVM_ABI unsigned getMaxDevirtIterations(const cl::LibraryOptionsContext &);
class LLVM_ABI CallGraphSCCPass : public Pass {
public:
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 3512c9c9a9ca29..07882a21a1b857 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -42,18 +42,16 @@ namespace cl {
class LibraryOptionsContext;
} // namespace cl
-/// Tunable parameters for passes in the default pipelines.
+/// Tunable parameters for passes in the default pipelines. An unset optional
+/// member takes the value of its library option in the PassBuilder's
+/// LLVMContext.
class PipelineTuningOptions {
public:
- /// Constructor sets pipeline tuning defaults based on the global values of
- /// the library options. Each option can be set in the PassBuilder when using
- /// a LLVM as a library.
- PipelineTuningOptions() : PipelineTuningOptions(nullptr) {}
+ LLVM_ABI PipelineTuningOptions();
- /// Reads the defaults from \p LibraryOptions, or their global values if
- /// null.
- LLVM_ABI explicit PipelineTuningOptions(
- const cl::LibraryOptionsContext *LibraryOptions);
+ /// Return a copy whose unset members are set from \p LibraryOptions.
+ [[nodiscard]] LLVM_ABI PipelineTuningOptions
+ resolve(const cl::LibraryOptionsContext &LibraryOptions) const;
/// Tuning option to set loop interleaving on/off, set based on opt level.
bool LoopInterleaving;
@@ -69,24 +67,22 @@ class PipelineTuningOptions {
/// Tuning option to enable/disable loop unrolling. Its default value is true.
bool LoopUnrolling;
- /// Tuning option to enable/disable loop interchange. Its default value is
- /// false.
- bool LoopInterchange;
+ /// Tuning option to enable/disable loop interchange.
+ std::optional<bool> LoopInterchange;
/// Tuning option to enable/disable loop fusion. Its default value is false.
bool LoopFusion;
- /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
- /// is that of the flag: `-forget-scev-loop-unroll`.
- bool ForgetAllSCEVInLoopUnroll;
+ /// Tuning option to forget all SCEV loops in LoopUnroll.
+ std::optional<bool> ForgetAllSCEVInLoopUnroll;
/// Tuning option to cap the number of calls to retrive clobbering accesses in
/// MemorySSA, in LICM.
- unsigned LicmMssaOptCap;
+ std::optional<unsigned> LicmMssaOptCap;
/// Tuning option to disable promotion to scalars in LICM with MemorySSA, if
/// the number of access is too large.
- unsigned LicmMssaNoAccForPromotionCap;
+ std::optional<unsigned> LicmMssaNoAccForPromotionCap;
/// Tuning option to enable/disable call graph profile. Its default value is
/// that of the flag: `-enable-npm-call-graph-profile`.
@@ -95,17 +91,15 @@ class PipelineTuningOptions {
// Add LTO pipeline tuning option to enable the unified LTO pipeline.
bool UnifiedLTO;
- /// Tuning option to enable/disable function merging. Its default value is
- /// false.
- bool MergeFunctions;
+ /// Tuning option to enable/disable function merging.
+ std::optional<bool> MergeFunctions;
/// Tuning option to override the default inliner threshold.
int InlinerThreshold;
/// Tuning option to cap how many times the inliner pipeline reruns on an SCC
- /// after devirtualizing a call. Its default value is that of the flag:
- /// `-max-devirt-iterations`.
- unsigned MaxDevirtIterations;
+ /// after devirtualizing a call.
+ std::optional<unsigned> MaxDevirtIterations;
// Experimental option to eagerly invalidate more analyses. This has the
// potential to decrease max memory usage in exchange for more compile time.
@@ -114,11 +108,10 @@ class PipelineTuningOptions {
// stale/imprecise but still valid. Currently this invalidates all function
// analyses after various module->function or cgscc->function adaptors in the
// default pipelines.
- bool EagerlyInvalidateAnalyses;
+ std::optional<bool> EagerlyInvalidateAnalyses;
// Tuning option to enable/disable speculative devirtualization.
- // Its default value is false.
- bool DevirtualizeSpeculatively;
+ std::optional<bool> DevirtualizeSpeculatively;
};
enum class PrintPipelinePassesFormat {
@@ -156,8 +149,8 @@ class PassBuilder {
};
/// The pipelines read the library options of \p Context, which must outlive
- /// the PassBuilder. If \p PTO is not given, it reads its defaults from
- /// \p Context.
+ /// the PassBuilder. Unset members of \p PTO, or all of them if \p PTO is not
+ /// given, are set from \p Context.
LLVM_ABI explicit PassBuilder(
LLVMContext &Context, TargetMachine *TM = nullptr,
std::optional<PipelineTuningOptions> PTO = std::nullopt,
diff --git a/llvm/include/llvm/Transforms/Scalar/LICM.h b/llvm/include/llvm/Transforms/Scalar/LICM.h
index 7eb460e7b33599..379dbd2152a308 100644
--- a/llvm/include/llvm/Transforms/Scalar/LICM.h
+++ b/llvm/include/llvm/Transforms/Scalar/LICM.h
@@ -45,14 +45,12 @@ namespace cl {
class LibraryOptionsContext;
} // namespace cl
-/// Returns -licm-mssa-optimization-cap of LibraryOptions, or its global value
-/// if null.
+/// Return -licm-mssa-optimization-cap.
LLVM_ABI unsigned
-getLicmMssaOptCap(const cl::LibraryOptionsContext *LibraryOptions);
-/// Returns -licm-mssa-max-acc-promotion of LibraryOptions, or its global value
-/// if null.
+getLicmMssaOptCap(const cl::LibraryOptionsContext &LibraryOptions);
+/// Return -licm-mssa-max-acc-promotion.
LLVM_ABI unsigned getLicmMssaNoAccForPromotionCap(
- const cl::LibraryOptionsContext *LibraryOptions);
+ const cl::LibraryOptionsContext &LibraryOptions);
struct LICMOptions {
// Unset means the -licm-mssa-* value of the loop's LLVMContext.
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h b/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
index 7955d8f79dc5c0..f2e50353b9b42e 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
@@ -19,10 +19,9 @@ namespace cl {
class LibraryOptionsContext;
} // namespace cl
-/// Returns -forget-scev-loop-unroll of LibraryOptions, or its global value if
-/// null.
+/// Return -forget-scev-loop-unroll.
LLVM_ABI bool
-getForgetSCEVInLoopUnroll(const cl::LibraryOptionsContext *LibraryOptions);
+getForgetSCEVInLoopUnroll(const cl::LibraryOptionsContext &LibraryOptions);
class Function;
class Loop;
diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index ba120b245275df..bff6aee0cad972 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -44,9 +44,8 @@ using namespace llvm;
#define DEBUG_TYPE "cgscc-passmgr"
unsigned
-llvm::getMaxDevirtIterations(const cl::LibraryOptionsContext *LibraryOptions) {
- return cl::LibraryOptionsContext::get<AnalysisOptions>(LibraryOptions)
- .max_devirt_iterations;
+llvm::getMaxDevirtIterations(const cl::LibraryOptionsContext &LibraryOptions) {
+ return LibraryOptions.get<AnalysisOptions>().max_devirt_iterations;
}
STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");
diff --git a/llvm/lib/DTLTO/CMakeLists.txt b/llvm/lib/DTLTO/CMakeLists.txt
index f40f5709321088..6296e0efd91ff0 100644
--- a/llvm/lib/DTLTO/CMakeLists.txt
+++ b/llvm/lib/DTLTO/CMakeLists.txt
@@ -11,5 +11,6 @@ add_llvm_component_library(LLVMDTLTO
Core
LTO
Object
+ Passes
Support
)
diff --git a/llvm/lib/DTLTO/DTLTO.cpp b/llvm/lib/DTLTO/DTLTO.cpp
index 669ba75c80d4b6..0f4ccc4cfe1a04 100644
--- a/llvm/lib/DTLTO/DTLTO.cpp
+++ b/llvm/lib/DTLTO/DTLTO.cpp
@@ -226,7 +226,10 @@ void lto::DTLTO::buildCommonRemoteCompilerOptions() {
Ops.push_back("-ffunction-sections");
if (C.Options.DataSections)
Ops.push_back("-fdata-sections");
- if (C.PTO.LoopInterchange)
+ // Match what an in-process backend resolves from C.LibraryOptions.
+ cl::LibraryOptionsContext NoLibraryOptions;
+ if (*C.PTO.resolve(C.LibraryOptions ? *C.LibraryOptions : NoLibraryOptions)
+ .LoopInterchange)
Ops.push_back("-floop-interchange");
if (C.RelocModel == Reloc::PIC_)
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index ad58b4fc3cf239..82a089a454dd21 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -564,7 +564,6 @@ bool LTOCodeGenerator::optimize() {
Config.RunCSIRInstr = LTORunCSIRInstr;
Config.CSIRProfile = LTOCSIRProfile;
Config.SampleProfile = SampleProfileFile;
- Config.PTO = PipelineTuningOptions(Config.LibraryOptions);
Config.PTO.LoopVectorization = Config.OptLevel > 1;
Config.PTO.SLPVectorization = Config.OptLevel > 1;
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 13e4c7bb5fc6f6..a2060b003ffa37 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -261,7 +261,7 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM,
PassInstrumentationCallbacks PIC;
StandardInstrumentations SI(TheModule.getContext(), DebugPassManager);
SI.registerCallbacks(PIC, &MAM);
- PipelineTuningOptions PTO(&TheModule.getContext().getLibraryOptions());
+ PipelineTuningOptions PTO;
PTO.LoopVectorization = true;
PTO.SLPVectorization = true;
PassBuilder PB(TheModule.getContext(), &TM, PTO, PGOOpt, &PIC);
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 8db9e561c825e4..3ca89c8d11163f 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -574,7 +574,8 @@ PassBuilder::PassBuilder(LLVMContext &Context, TargetMachine *TM,
PassInstrumentationCallbacks *PIC,
IntrusiveRefCntPtr<vfs::FileSystem> FS)
: Context(Context), Opts(getPassesOptions(Context)), TM(TM),
- PTO(PTO ? *PTO : PipelineTuningOptions(&Context.getLibraryOptions())),
+ PTO(PTO.value_or(PipelineTuningOptions())
+ .resolve(Context.getLibraryOptions())),
PGOOpt(PGOOpt), PIC(PIC), FS(std::move(FS)) {
if (TM)
TM->registerPassBuilderCallbacks(*this);
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index d1229a93ecf275..b815fe6e80113b 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -170,27 +170,35 @@ extern cl::opt<bool> EnableMemProfContextDisambiguation;
extern cl::opt<bool> EnableProfcheckInPipeline;
} // namespace llvm
-PipelineTuningOptions::PipelineTuningOptions(
- const cl::LibraryOptionsContext *LibraryOptions) {
- const PassesOptions &Opts =
- cl::LibraryOptionsContext::get<PassesOptions>(LibraryOptions);
+PipelineTuningOptions::PipelineTuningOptions() {
LoopInterleaving = true;
LoopVectorization = true;
SLPVectorization = false;
LoopUnrolling = true;
- LoopInterchange = Opts.enable_loopinterchange;
LoopFusion = false;
- ForgetAllSCEVInLoopUnroll = getForgetSCEVInLoopUnroll(LibraryOptions);
- LicmMssaOptCap = getLicmMssaOptCap(LibraryOptions);
- LicmMssaNoAccForPromotionCap =
- getLicmMssaNoAccForPromotionCap(LibraryOptions);
CallGraphProfile = true;
UnifiedLTO = false;
- MergeFunctions = Opts.enable_merge_functions;
InlinerThreshold = -1;
- MaxDevirtIterations = getMaxDevirtIterations(LibraryOptions);
- EagerlyInvalidateAnalyses = Opts.eagerly_invalidate_analyses;
- DevirtualizeSpeculatively = Opts.enable_devirtualize_speculatively;
+}
+
+PipelineTuningOptions PipelineTuningOptions::resolve(
+ const cl::LibraryOptionsContext &LibraryOptions) const {
+ const PassesOptions &Opts = LibraryOptions.get<PassesOptions>();
+ PipelineTuningOptions R = *this;
+ R.LoopInterchange = LoopInterchange.value_or(Opts.enable_loopinterchange);
+ R.ForgetAllSCEVInLoopUnroll = ForgetAllSCEVInLoopUnroll.value_or(
+ getForgetSCEVInLoopUnroll(LibraryOptions));
+ R.LicmMssaOptCap = LicmMssaOptCap.value_or(getLicmMssaOptCap(LibraryOptions));
+ R.LicmMssaNoAccForPromotionCap = LicmMssaNoAccForPromotionCap.value_or(
+ getLicmMssaNoAccForPromotionCap(LibraryOptions));
+ R.MergeFunctions = MergeFunctions.value_or(Opts.enable_merge_functions);
+ R.MaxDevirtIterations =
+ MaxDevirtIterations.value_or(getMaxDevirtIterations(LibraryOptions));
+ R.EagerlyInvalidateAnalyses =
+ EagerlyInvalidateAnalyses.value_or(Opts.eagerly_invalidate_analyses);
+ R.DevirtualizeSpeculatively = DevirtualizeSpeculatively.value_or(
+ Opts.enable_devirtualize_speculatively);
+ return R;
}
void PassBuilder::invokePeepholeEPCallbacks(FunctionPassManager &FPM,
@@ -425,13 +433,13 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
// will destroy metadata that may not need to be destroyed if run
// after loop rotation.
// TODO: Investigate promotion cap for O1.
- LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ LPM1.addPass(LICMPass(*PTO.LicmMssaOptCap, *PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/false));
LPM1.addPass(
LoopRotatePass(/*EnableHeaderDuplication=*/true, isLTOPreLink(Phase)));
// TODO: Investigate promotion cap for O1.
- LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ LPM1.addPass(LICMPass(*PTO.LicmMssaOptCap, *PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
LPM1.addPass(SimpleLoopUnswitchPass());
if (Opts.enable_loop_flatten)
@@ -453,7 +461,7 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
PGOOpt->Action != PGOOptions::SampleUse)
LPM2.addPass(LoopFullUnrollPass(static_cast<int>(Level),
/* OnlyWhenForced= */ !PTO.LoopUnrolling,
- PTO.ForgetAllSCEVInLoopUnroll));
+ *PTO.ForgetAllSCEVInLoopUnroll));
invokeLoopOptimizerEndEPCallbacks(LPM2, Level);
@@ -599,13 +607,13 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
// will destroy metadata that may not need to be destroyed if run
// after loop rotation.
// TODO: Investigate promotion cap for O1.
- LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ LPM1.addPass(LICMPass(*PTO.LicmMssaOptCap, *PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/false));
LPM1.addPass(
LoopRotatePass(/*EnableHeaderDuplication=*/true, isLTOPreLink(Phase)));
// TODO: Investigate promotion cap for O1.
- LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ LPM1.addPass(LICMPass(*PTO.LicmMssaOptCap, *PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
LPM1.addPass(
SimpleLoopUnswitchPass(/* NonTrivial */ Level == OptimizationLevel::O3));
@@ -635,7 +643,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
PGOOpt->Action != PGOOptions::SampleUse)
LPM2.addPass(LoopFullUnrollPass(static_cast<int>(Level),
/* OnlyWhenForced= */ !PTO.LoopUnrolling,
- PTO.ForgetAllSCEVInLoopUnroll));
+ *PTO.ForgetAllSCEVInLoopUnroll));
invokeLoopOptimizerEndEPCallbacks(LPM2, Level);
@@ -699,7 +707,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
FPM.addPass(MoveAutoInitPass());
FPM.addPass(createFunctionToLoopPassAdaptor(
- LICMPass(PTO.LicmMssaOptC...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/238434
More information about the Mlir-commits
mailing list