Index: lib/Passes/PassBuilder.cpp =================================================================== --- lib/Passes/PassBuilder.cpp +++ lib/Passes/PassBuilder.cpp @@ -155,10 +155,11 @@ static cl::opt MaxDevirtIterations("pm-max-devirt-iterations", cl::ReallyHidden, cl::init(4)); + static cl::opt - RunPartialInlining("enable-npm-partial-inlining", cl::init(false), + RunPartialInliningThinLTOPreLink("enable-npm-lto-prelink-partial-inlining", cl::init(true), cl::Hidden, cl::ZeroOrMore, - cl::desc("Run Partial inlinining pass")); + cl::desc("Run Partial inlining pass during thinLTO prelink")); static cl::opt RunNewGVN("enable-npm-newgvn", cl::init(false), @@ -691,8 +692,7 @@ // Run partial inlining pass to partially inline functions that have // large bodies. - if (RunPartialInlining) - MPM.addPass(PartialInlinerPass()); + MPM.addPass(PartialInlinerPass()); // Remove avail extern fns and globals definitions since we aren't compiling // an object file for later LTO. For LTO we want to preserve these so they @@ -861,7 +861,7 @@ // phase that will run after the thin link, running this here ends up with // less information than will be available later and it may grow functions in // ways that aren't beneficial. - if (RunPartialInlining) + if (RunPartialInliningThinLTOPreLink) MPM.addPass(PartialInlinerPass()); // Reduce the size of the IR as much as possible. Index: lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- lib/Transforms/IPO/PassManagerBuilder.cpp +++ lib/Transforms/IPO/PassManagerBuilder.cpp @@ -44,8 +44,9 @@ using namespace llvm; static cl::opt - RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden, - cl::ZeroOrMore, cl::desc("Run Partial inlinining pass")); + RunPartialInliningThinLTOPreLink("enable-lto-prelink-partial-inlining", cl::init(false), + cl::Hidden, cl::ZeroOrMore, + cl::desc("Run Partial inlining pass during thinLTO prelink")); static cl::opt RunLoopVectorization("vectorize-loops", cl::Hidden, @@ -517,7 +518,9 @@ // we must insert a no-op module pass to reset the pass manager. MPM.add(createBarrierNoopPass()); - if (RunPartialInlining) + // Only run partial inlining when we're either i) not preparing for thinLTO, + // or ii) preparing for thinLTO AND we've turned on the CL option. + if (!PrepareForThinLTO || (PrepareForThinLTO && RunPartialInliningThinLTOPreLink)) MPM.add(createPartialInliningPass()); if (OptLevel > 1 && !PrepareForLTO && !PrepareForThinLTO)