[llvm] d312788 - [InlineOrder] fix the calculation of Cost for CostBenefitPriority (#86630)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 15:59:35 PDT 2024
Author: Xiangyang (Mark) Guo
Date: 2024-03-26T15:59:31-07:00
New Revision: d31278896208d856b277e34bd7e2a63899f0b57b
URL: https://github.com/llvm/llvm-project/commit/d31278896208d856b277e34bd7e2a63899f0b57b
DIFF: https://github.com/llvm/llvm-project/commit/d31278896208d856b277e34bd7e2a63899f0b57b.diff
LOG: [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 <helloguo at meta.com>
Added:
Modified:
llvm/lib/Analysis/InlineOrder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp
index 09fc4f9a00f49c..f156daa2f126fb 100644
--- a/llvm/lib/Analysis/InlineOrder.cpp
+++ b/llvm/lib/Analysis/InlineOrder.cpp
@@ -114,7 +114,10 @@ class CostBenefitPriority {
CostBenefitPriority(const CallBase *CB, FunctionAnalysisManager &FAM,
const InlineParams &Params) {
auto IC = getInlineCostWrapper(const_cast<CallBase &>(*CB), FAM, Params);
- Cost = IC.getCost();
+ if (IC.isVariable())
+ Cost = IC.getCost();
+ else
+ Cost = IC.isNever() ? INT_MAX : INT_MIN;
StaticBonusApplied = IC.getStaticBonusApplied();
CostBenefit = IC.getCostBenefit();
}
More information about the llvm-commits
mailing list