diff options
author | Liqiang Tao <taolq@outlook.com> | 2021-07-25 20:17:30 +0800 |
---|---|---|
committer | Liqiang Tao <taolq@outlook.com> | 2021-07-25 20:18:19 +0800 |
commit | 4bdfea2c515275136eaff8de9666e5c2ee913748 (patch) | |
tree | 972b1f6d4ea6f4fff56dc738026c1dbe1d989a88 /llvm/lib/Analysis/InlineCost.cpp | |
parent | acbc0c5f0ebd8b7ebfa2eb3ae77428eb83c428c5 (diff) | |
download | llvm-4bdfea2c515275136eaff8de9666e5c2ee913748.zip llvm-4bdfea2c515275136eaff8de9666e5c2ee913748.tar.gz llvm-4bdfea2c515275136eaff8de9666e5c2ee913748.tar.bz2 |
[llvm][Inline] Add interface to return cost-benefit stuff
Return cost-benefit stuff which is computed by cost-benefit analysis.
Reviewed By: mtrofin
Differential Revision: https://reviews.llvm.org/D105349
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 0522ddf..030bfc1 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -509,6 +509,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { // Whether inlining is decided by cost-benefit analysis. bool DecidedByCostBenefit = false; + // The cost-benefit pair computed by cost-benefit analysis. + Optional<CostBenefitPair> CostBenefit = None; + bool SingleBB = true; unsigned SROACostSavings = 0; @@ -794,6 +797,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { // savings threshold. Size = Size > InlineSizeAllowance ? Size - InlineSizeAllowance : 1; + CostBenefit.emplace(APInt(128, Size), CycleSavings); + // Return true if the savings justify the cost of inlining. Specifically, // we evaluate the following inequality: // @@ -941,6 +946,7 @@ public: virtual ~InlineCostCallAnalyzer() {} int getThreshold() const { return Threshold; } int getCost() const { return Cost; } + Optional<CostBenefitPair> getCostBenefitPair() { return CostBenefit; } bool wasDecidedByCostBenefit() const { return DecidedByCostBenefit; } }; @@ -2834,9 +2840,10 @@ InlineCost llvm::getInlineCost( // as it's not what drives cost-benefit analysis. if (CA.wasDecidedByCostBenefit()) { if (ShouldInline.isSuccess()) - return InlineCost::getAlways("benefit over cost"); + return InlineCost::getAlways("benefit over cost", + CA.getCostBenefitPair()); else - return InlineCost::getNever("cost over benefit"); + return InlineCost::getNever("cost over benefit", CA.getCostBenefitPair()); } // Check if there was a reason to force inlining or no inlining. |