[llvm] 4bdc938 - [CSSPGO][Preinliner] Always inline zero-sized functions.
Hongtao Yu via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 17:12:29 PDT 2023
Author: Hongtao Yu
Date: 2023-06-27T17:06:24-07:00
New Revision: 4bdc938ce3f0bc7721d1942b23cd49734121094a
URL: https://github.com/llvm/llvm-project/commit/4bdc938ce3f0bc7721d1942b23cd49734121094a
DIFF: https://github.com/llvm/llvm-project/commit/4bdc938ce3f0bc7721d1942b23cd49734121094a.diff
LOG: [CSSPGO][Preinliner] Always inline zero-sized functions.
Zero-sized functions should be cost-free in term of size budget, so they should be considered during inlining even if we run out of size budget.
This appears to give 0.5% win for one of our internal services.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D153820
Added:
Modified:
llvm/tools/llvm-profgen/CSPreInliner.h
Removed:
################################################################################
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;
More information about the llvm-commits
mailing list