diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -1708,11 +1708,17 @@ // valuable as the inliner doesn't currently care whether it is inlining an // invoke or a call. // Run the inliner now. - MPM.addPass(ModuleInlinerWrapperPass( - getInlineParamsFromOptLevel(Level), - /* MandatoryFirst */ true, - InlineContext{ThinOrFullLTOPhase::FullLTOPostLink, - InlinePass::CGSCCInliner})); + if (EnableModuleInliner) { + MPM.addPass(ModuleInlinerPass(getInlineParamsFromOptLevel(Level), + UseInlineAdvisor, + ThinOrFullLTOPhase::FullLTOPostLink)); + } else { + MPM.addPass(ModuleInlinerWrapperPass( + getInlineParamsFromOptLevel(Level), + /* MandatoryFirst */ true, + InlineContext{ThinOrFullLTOPhase::FullLTOPostLink, + InlinePass::CGSCCInliner})); + } // Perform context disambiguation after inlining, since that would reduce the // amount of additional cloning required to distinguish the allocation