Skip to content

Commit d312788

Browse files
authored
[InlineOrder] fix the calculation of Cost for CostBenefitPriority (#86630)
getCost() expects that isVariable() is true. https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Analysis/InlineCost.h#L146 Co-authored-by: helloguo <[email protected]>
1 parent 8669225 commit d312788

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Analysis/InlineOrder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ class CostBenefitPriority {
114114
CostBenefitPriority(const CallBase *CB, FunctionAnalysisManager &FAM,
115115
const InlineParams &Params) {
116116
auto IC = getInlineCostWrapper(const_cast<CallBase &>(*CB), FAM, Params);
117-
Cost = IC.getCost();
117+
if (IC.isVariable())
118+
Cost = IC.getCost();
119+
else
120+
Cost = IC.isNever() ? INT_MAX : INT_MIN;
118121
StaticBonusApplied = IC.getStaticBonusApplied();
119122
CostBenefit = IC.getCostBenefit();
120123
}

0 commit comments

Comments
 (0)