diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp --- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp +++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp @@ -545,6 +545,8 @@ ToSamples->merge(*FromSamples); ToSamples->getContext().setState(SyntheticContext); FromSamples->getContext().setState(MergedContext); + if (FromSamples->getContext().hasAttribute(ContextShouldBeInlined)) + ToSamples->getContext().setAttribute(ContextShouldBeInlined); } else if (FromSamples) { // Transfer FromSamples from FromNode to ToNode ToNode.setFunctionSamples(FromSamples); diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -977,7 +977,14 @@ // For CSSPGO profile, retrieve candidate profile by walking over the // trie built for context profile. Note that also take call targets // even if callee doesn't have a corresponding context profile. - if (!CalleeSample || CalleeSample->getEntrySamples() < Threshold) + if (!CalleeSample) + continue; + + // If pre-inliner decision is used, honor that for importing as well. + bool PreInline = + UsePreInlinerDecision && + CalleeSample->getContext().hasAttribute(ContextShouldBeInlined); + if (!PreInline && CalleeSample->getEntrySamples() < Threshold) continue; StringRef Name = CalleeSample->getFuncName();