[PATCH] D145516: [Inliner] Avoid excessive inlining through devirtualised calls

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 11:05:59 PDT 2023


jmorse added inline comments.


================
Comment at: llvm/lib/Analysis/InlineCost.cpp:683
         // threshold to get the bonus we want to apply, but don't go below zero.
-        Cost -= std::max(0, CA.getThreshold() - CA.getCost());
+        Cost -= std::min(Cost, std::max(0, CA.getThreshold() - CA.getCost()));
       }
----------------
aeubanks wrote:
> is this change intended?
It is, it puts a ceiling on the outer subtraction so that the cost is never reduced to be below zero. While the comment says that negative-costs have been considered, I think that only applies to the inner subtraction, as I've seen negative numbers produced here during testing.

I can split this out into a different patch if needs be, but I'm not sure how to write a test for it. As far as I understand it, the cost can only be observed by passing `-debug` to LLVM, and I'm under the impression that that's generally discouraged in tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145516/new/

https://reviews.llvm.org/D145516



More information about the llvm-commits mailing list