================
@@ -214,9 +241,18 @@ void CSPreInliner::processFunction(const FunctionId Name) {
   ProfiledCandidateQueue CQueue;
   getInlineCandidates(CQueue, FSamples);
 
-  while (!CQueue.empty() && FuncFinalSize < SizeLimit) {
+  // Candidates left out because the size budget is spent.
+  SmallVector<ProfiledInlineCandidate> OverBudget;
+  while (!CQueue.empty()) {
     ProfiledInlineCandidate Candidate = CQueue.top();
     CQueue.pop();
+    // Inlines always_inline callees regardless of the budget.
+    if (FuncFinalSize >= SizeLimit &&
----------------
kunalspathak wrote:

The budget bypass here, and the `ChargeAlwaysInlineSize || !IsAlwaysInline` 
check below, don't look at `SamplePreInlineReplay`, so 
`-csspgo-replay-preinline` behaves differently with the default flags now. In 
the replay mode `shouldInline()` just returns `WasInlined`, but this loop was 
still enforceing the size budget. Before this patch an `always_inline` callee 
that was inlined got charged, so it could use up the budget and push out other 
callees the binary had inlined. Now it is no longer getting charged (with 
default flags). Using the numbers from the test: `main` is 178 bytes, the 
budget is 250 (as in the FREE/CHARGED runs), and the binary inlined both `ai` 
(78 bytes) and `ord`. Before, `ai` takes `main` to 256, so `ord` no longer fits 
and replay drops it even though the binary inlined it. Now `ai` costs nothing, 
`ord` fits and gets replayed. That's probably closer to what the binary did, so 
I am ok with that. But the replay behavior change should be documented IMO. 
Could you call it out in the description/comment here, and maybe add a replay 
RUN line to the test?

https://github.com/llvm/llvm-project/pull/234094
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to