diff --git a/llvm/tools/llvm-profgen/CSPreInliner.h b/llvm/tools/llvm-profgen/CSPreInliner.h index 09dd2dec1149c..4d848aafdab91 100644 --- a/llvm/tools/llvm-profgen/CSPreInliner.h +++ b/llvm/tools/llvm-profgen/CSPreInliner.h @@ -41,6 +41,13 @@ struct ProfiledInlineCandidate { struct ProfiledCandidateComparer { bool operator()(const ProfiledInlineCandidate &LHS, const ProfiledInlineCandidate &RHS) { + // Always prioritize inlining zero-sized functions as they do not affect the + // size budget. This could happen when all of the callee's code is gone and + // only pseudo probes are left. + if ((LHS.SizeCost == 0 || RHS.SizeCost == 0) && + (LHS.SizeCost != RHS.SizeCost)) + return RHS.SizeCost == 0; + if (LHS.CallsiteCount != RHS.CallsiteCount) return LHS.CallsiteCount < RHS.CallsiteCount;