diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 5cc2911a1a80e..6af284d513efc 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -439,7 +439,10 @@ struct CandidateComparer { const FunctionSamples *LCS = LHS.CalleeSamples; const FunctionSamples *RCS = RHS.CalleeSamples; - assert(LCS && RCS && "Expect non-null FunctionSamples"); + // In inline replay mode, CalleeSamples may be null and the order doesn't + // matter. + if (!LCS || !RCS) + return LCS; // Tie breaker using number of samples try to favor smaller functions first if (LCS->getBodySamples().size() != RCS->getBodySamples().size())