From: Wenlei He Date: Fri, 19 Feb 2021 04:11:58 +0000 (-0800) Subject: [SampleFDO] Skip PreLink ICP for better profile quality of MonoLTO PostLink X-Git-Tag: llvmorg-14-init~14544 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a952d7291e99aded397073f61e091c0f011da779;p=platform%2Fupstream%2Fllvm.git [SampleFDO] Skip PreLink ICP for better profile quality of MonoLTO PostLink For ThinLTO, PreLink ICP is skipped to favor better profile annotation during LTO PostLink. This change applies the same tweak for MonoLTO. Note that PreLink ICP not only makes PostLink profile annotation harder, it is also uncoordinated with PostLink ICP so duplicated ICP could happen. Differential Revision: https://reviews.llvm.org/D97028 --- diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 1e75690d554d..c3f9c7e0903f 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1081,15 +1081,16 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, // Cache ProfileSummaryAnalysis once to avoid the potential need to insert // RequireAnalysisPass for PSI before subsequent non-module passes. MPM.addPass(RequireAnalysisPass()); - // Do not invoke ICP in the ThinLTOPrelink phase as it makes it hard - // for the profile annotation to be accurate in the ThinLTO backend. - if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink) + // Do not invoke ICP in the LTOPrelink phase as it makes it hard + // for the profile annotation to be accurate in the LTO backend. + if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink && + Phase != ThinOrFullLTOPhase::FullLTOPreLink) // We perform early indirect call promotion here, before globalopt. // This is important for the ThinLTO backend phase because otherwise // imported available_externally functions look unreferenced and are // removed. - MPM.addPass(PGOIndirectCallPromotion( - Phase == ThinOrFullLTOPhase::ThinLTOPostLink, true /* SamplePGO */)); + MPM.addPass( + PGOIndirectCallPromotion(true /* IsInLTO */, true /* SamplePGO */)); } if (AttributorRun & AttributorRunOption::MODULE)