[llvm] cfc4def - [NFC] Code cleanups in InlineCost.cpp.
Jacob Hegna via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 21 17:03:47 PDT 2021
Author: Jacob Hegna
Date: 2021-07-22T00:03:36Z
New Revision: cfc4def85df51aa70c7168711de3591ec0169d60
URL: https://github.com/llvm/llvm-project/commit/cfc4def85df51aa70c7168711de3591ec0169d60
DIFF: https://github.com/llvm/llvm-project/commit/cfc4def85df51aa70c7168711de3591ec0169d60.diff
LOG: [NFC] Code cleanups in InlineCost.cpp.
- annotate const functions with "const"
- replace C-style casts with static_cast
Differential Revision: https://reviews.llvm.org/D105362
Added:
Modified:
llvm/lib/Analysis/InlineCost.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 1b6ac94979a95..0522ddf5e25e1 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -534,7 +534,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
/// 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 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// 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 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
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 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
}
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 {
More information about the llvm-commits
mailing list