[PATCH] D99302: [InlineCost] Make cost-benefit decision explicit
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 24 15:44:21 PDT 2021
wenlei updated this revision to Diff 333160.
wenlei added a comment.
Address David's feedback, also make negative decision explicit.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99302/new/
https://reviews.llvm.org/D99302
Files:
llvm/lib/Analysis/InlineCost.cpp
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -489,6 +489,9 @@
// sense that it's not weighted by profile counts at all.
int ColdSize = 0;
+ // Whether inlining is decided by cost-benefit analysis.
+ bool DecidedByCostBenefit = false;
+
bool SingleBB = true;
unsigned SROACostSavings = 0;
@@ -825,6 +828,7 @@
Threshold -= VectorBonus / 2;
if (auto Result = costBenefitAnalysis()) {
+ DecidedByCostBenefit = true;
if (Result.getValue())
return InlineResult::success();
else
@@ -926,6 +930,7 @@
virtual ~InlineCostCallAnalyzer() {}
int getThreshold() { return Threshold; }
int getCost() { return Cost; }
+ bool wasDecidedByCostBenefit() { return DecidedByCostBenefit; }
};
} // namespace
@@ -2609,6 +2614,16 @@
LLVM_DEBUG(CA.dump());
+ // Always make cost benefit based decision explicit.
+ // We use always/never here since threshold is not meaningful,
+ // as it's not what drives cost-benefit analysis.
+ if (CA.wasDecidedByCostBenefit()) {
+ if (ShouldInline.isSuccess())
+ return InlineCost::getAlways("benefit over cost");
+ else
+ return InlineCost::getNever("cost over benefit");
+ }
+
// Check if there was a reason to force inlining or no inlining.
if (!ShouldInline.isSuccess() && CA.getCost() < CA.getThreshold())
return InlineCost::getNever(ShouldInline.getFailureReason());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99302.333160.patch
Type: text/x-patch
Size: 1538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210324/2f94ef45/attachment.bin>
More information about the llvm-commits
mailing list