diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/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(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(JumpTableSize) * InlineConstants::InstrCost + + 4 * InlineConstants::InstrCost; - addCost(JTCost, (int64_t)CostUpperBound); + addCost(JTCost, static_cast(CostUpperBound)); return; } @@ -613,7 +614,7 @@ int64_t SwitchCost = ExpectedNumberOfCompare * 2 * InlineConstants::InstrCost; - addCost(SwitchCost, (int64_t)CostUpperBound); + addCost(SwitchCost, static_cast(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 {