[PATCH] D105362: [NFC] Code cleanups in InlineCost.cpp.

Jacob Hegna via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 21 17:04:02 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfc4def85df5: [NFC] Code cleanups in InlineCost.cpp. (authored by jacobhegna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105362

Files:
  llvm/lib/Analysis/InlineCost.cpp


Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -534,7 +534,7 @@
   /// Handle a capped 'int' increment for Cost.
   void addCost(int64_t Inc, int64_t UpperBound = INT_MAX) {
     assert(UpperBound > 0 && UpperBound <= INT_MAX && "invalid upper bound");
-    Cost = (int)std::min(UpperBound, Cost + Inc);
+    Cost = std::min<int>(UpperBound, Cost + Inc);
   }
 
   void onDisableSROA(AllocaInst *Arg) override {
@@ -595,10 +595,11 @@
     // branch to destination.
     // Maximum valid cost increased in this function.
     if (JumpTableSize) {
-      int64_t JTCost = (int64_t)JumpTableSize * InlineConstants::InstrCost +
-                       4 * InlineConstants::InstrCost;
+      int64_t JTCost =
+          static_cast<int64_t>(JumpTableSize) * InlineConstants::InstrCost +
+          4 * InlineConstants::InstrCost;
 
-      addCost(JTCost, (int64_t)CostUpperBound);
+      addCost(JTCost, static_cast<int64_t>(CostUpperBound));
       return;
     }
 
@@ -613,7 +614,7 @@
     int64_t SwitchCost =
         ExpectedNumberOfCompare * 2 * InlineConstants::InstrCost;
 
-    addCost(SwitchCost, (int64_t)CostUpperBound);
+    addCost(SwitchCost, static_cast<int64_t>(CostUpperBound));
   }
   void onMissedSimplification() override {
     addCost(InlineConstants::InstrCost);
@@ -938,9 +939,9 @@
   }
 
   virtual ~InlineCostCallAnalyzer() {}
-  int getThreshold() { return Threshold; }
-  int getCost() { return Cost; }
-  bool wasDecidedByCostBenefit() { return DecidedByCostBenefit; }
+  int getThreshold() const { return Threshold; }
+  int getCost() const { return Cost; }
+  bool wasDecidedByCostBenefit() const { return DecidedByCostBenefit; }
 };
 
 class InlineCostFeaturesAnalyzer final : public CallAnalyzer {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105362.360652.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/02411a47/attachment.bin>


More information about the llvm-commits mailing list