[llvm] 13a40e3 - [Analysis] Use the addCost() helper across InlineCost.cpp (#141901)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 01:15:50 PDT 2025


Author: Gleb Popov
Date: 2025-10-23T10:15:46+02:00
New Revision: 13a40e38924a04fd5ddf0cbfefd9861521f362ba

URL: https://github.com/llvm/llvm-project/commit/13a40e38924a04fd5ddf0cbfefd9861521f362ba
DIFF: https://github.com/llvm/llvm-project/commit/13a40e38924a04fd5ddf0cbfefd9861521f362ba.diff

LOG: [Analysis] Use the addCost() helper across InlineCost.cpp (#141901)

For the sake of consistency.

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 757f68999691e..c4fee39cc0766 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -751,7 +751,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
       if (CA.analyze().isSuccess()) {
         // We were able to inline the indirect call! Subtract the cost from the
         // threshold to get the bonus we want to apply, but don't go below zero.
-        Cost -= std::max(0, CA.getThreshold() - CA.getCost());
+        addCost(-std::max(0, CA.getThreshold() - CA.getCost()));
       }
     } else
       // Otherwise simply add the cost for merely making the call.
@@ -1191,7 +1191,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
     // If this function uses the coldcc calling convention, prefer not to inline
     // it.
     if (F.getCallingConv() == CallingConv::Cold)
-      Cost += InlineConstants::ColdccPenalty;
+      addCost(InlineConstants::ColdccPenalty);
 
     LLVM_DEBUG(dbgs() << "      Initial cost: " << Cost << "\n");
 
@@ -2193,7 +2193,7 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
   // the cost of inlining it drops dramatically. It may seem odd to update
   // Cost in updateThreshold, but the bonus depends on the logic in this method.
   if (isSoleCallToLocalFunction(Call, F)) {
-    Cost -= LastCallToStaticBonus;
+    addCost(-LastCallToStaticBonus);
     StaticBonusApplied = LastCallToStaticBonus;
   }
 }


        


More information about the llvm-commits mailing list