diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp --- a/llvm/tools/llvm-profgen/CSPreInliner.cpp +++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp @@ -153,11 +153,12 @@ } bool CSPreInliner::shouldInline(ProfiledInlineCandidate &Candidate) { + bool WasInlined = + Candidate.CalleeSamples->getContext().hasAttribute(ContextWasInlined); // If replay inline is requested, simply follow the inline decision of the // profiled binary. if (SamplePreInlineReplay) - return Candidate.CalleeSamples->getContext().hasAttribute( - ContextWasInlined); + return WasInlined; unsigned int SampleThreshold = SampleColdCallSiteThreshold; uint64_t ColdCountThreshold = ProfileSummaryBuilder::getColdCountThreshold( @@ -184,6 +185,12 @@ // want any inlining for cold callsites. SampleThreshold = SampleHotCallSiteThreshold * NormalizedHotness * 100 + SampleColdCallSiteThreshold + 1; + // Bump up the threshold to favor previous compiler inline decision. The + // compiler has more insight and knowledge about functions based on their IR + // and attribures and should be able to make a more reasonable inline + // decision. + if (WasInlined) + SampleThreshold *= 100; } return (Candidate.SizeCost < SampleThreshold);