summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp28
-rw-r--r--llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll6
-rw-r--r--llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks.ll4
-rw-r--r--llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll4
-rw-r--r--llvm/test/LTO/X86/diagnostic-handler-remarks.ll4
-rw-r--r--llvm/test/Transforms/Inline/ARM/inline-fp.ll12
6 files changed, 30 insertions, 28 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 3cb56f8cccf..b7b58d8aca3 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -897,7 +897,15 @@ void CallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
// and the callsite.
int SingleBBBonusPercent = 50;
int VectorBonusPercent = 150;
- int LastCallToStaticBonus = InlineConstants::LastCallToStaticBonus;
+
+ int LastCallToStaticBonus = 0;
+ bool OnlyOneCallAndLocalLinkage =
+ F.hasLocalLinkage() && F.hasOneUse() && &F == Call.getCalledFunction();
+ // If there is only one call of the function, and it has internal linkage,
+ // we can allow to inline pretty anything as it will lead to size reduction
+ // anyway.
+ if (OnlyOneCallAndLocalLinkage)
+ LastCallToStaticBonus = InlineConstants::LastCallToStaticBonus;
// Lambda to set all the above bonus and bonus percentages to 0.
auto DisallowAllBonuses = [&]() {
@@ -970,20 +978,13 @@ void CallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
}
}
- // Finally, take the target-specific inlining threshold multiplier into
- // account.
+ // Take the target-specific inlining threshold multiplier into account.
Threshold *= TTI.getInliningThresholdMultiplier();
SingleBBBonus = Threshold * SingleBBBonusPercent / 100;
VectorBonus = Threshold * VectorBonusPercent / 100;
- bool OnlyOneCallAndLocalLinkage =
- F.hasLocalLinkage() && F.hasOneUse() && &F == Call.getCalledFunction();
- // If there is only one call of the function, and it has internal linkage,
- // the cost of inlining it drops dramatically. It may seem odd to update
- // Cost in updateThreshold, but the bonus depends on the logic in this method.
- if (OnlyOneCallAndLocalLinkage)
- Cost -= LastCallToStaticBonus;
+ Threshold += LastCallToStaticBonus;
}
bool CallAnalyzer::visitCmpInst(CmpInst &I) {
@@ -1330,9 +1331,10 @@ bool CallAnalyzer::visitCallBase(CallBase &Call) {
CallAnalyzer CA(TTI, GetAssumptionCache, GetBFI, PSI, ORE, *F, Call,
IndirectCallParams);
if (CA.analyzeCall(Call)) {
- // We were able to inline the indirect call! Subtract the cost from the
- // threshold to get the bonus we want to apply, but don't go below zero.
- Cost -= std::max(0, CA.getThreshold() - CA.getCost());
+ // We were able to inline the indirect call! Increase the threshold
+ // with the bonus we want to apply (less the cost of inlinee).
+ // Make sure the bonus doesn't go below zero.
+ Threshold += std::max(0, CA.getThreshold() - CA.getCost());
}
if (!F->onlyReadsMemory())
diff --git a/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll b/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
index 9932f527dc6..6b5a338e412 100644
--- a/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
+++ b/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
@@ -27,13 +27,13 @@
; YAML-NEXT: - Caller: main
; YAML-NEXT: - String: ' with '
; YAML-NEXT: - String: '(cost='
-; YAML-NEXT: - Cost: '-15000'
+; YAML-NEXT: - Cost: '0'
; YAML-NEXT: - String: ', threshold='
-; YAML-NEXT: - Threshold: '337'
+; YAML-NEXT: - Threshold: '15337'
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
-; CHECK: tinkywinky inlined into main with (cost=-15000, threshold=337) (hotness: 300)
+; CHECK: tinkywinky inlined into main with (cost=0, threshold=15337) (hotness: 300)
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-scei-ps4"
diff --git a/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks.ll b/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks.ll
index beb0f4fa49b..72f10235a81 100644
--- a/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks.ll
+++ b/llvm/test/LTO/Resolution/X86/diagnostic-handler-remarks.ll
@@ -30,9 +30,9 @@
; YAML-NEXT: - Caller: main
; YAML-NEXT: - String: ' with '
; YAML-NEXT: - String: '(cost='
-; YAML-NEXT: - Cost: '-15000'
+; YAML-NEXT: - Cost: '0'
; YAML-NEXT: - String: ', threshold='
-; YAML-NEXT: - Threshold: '337'
+; YAML-NEXT: - Threshold: '15337'
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
diff --git a/llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll b/llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
index d1dddf1a71f..ab4003d0e09 100644
--- a/llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
+++ b/llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
@@ -19,9 +19,9 @@
; YAML-NEXT: - Caller: main
; YAML-NEXT: - String: ' with '
; YAML-NEXT: - String: '(cost='
-; YAML-NEXT: - Cost: '-15000'
+; YAML-NEXT: - Cost: '0'
; YAML-NEXT: - String: ', threshold='
-; YAML-NEXT: - Threshold: '337'
+; YAML-NEXT: - Threshold: '15337'
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
diff --git a/llvm/test/LTO/X86/diagnostic-handler-remarks.ll b/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
index 94f88ec43c5..dd4086fb587 100644
--- a/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
+++ b/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
@@ -55,9 +55,9 @@
; YAML-NEXT: - Caller: main
; YAML-NEXT: - String: ' with '
; YAML-NEXT: - String: '(cost='
-; YAML-NEXT: - Cost: '-15000'
+; YAML-NEXT: - Cost: '0'
; YAML-NEXT: - String: ', threshold='
-; YAML-NEXT: - Threshold: '337'
+; YAML-NEXT: - Threshold: '15337'
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
diff --git a/llvm/test/Transforms/Inline/ARM/inline-fp.ll b/llvm/test/Transforms/Inline/ARM/inline-fp.ll
index 1d74dfd15b1..a8e486eb0a5 100644
--- a/llvm/test/Transforms/Inline/ARM/inline-fp.ll
+++ b/llvm/test/Transforms/Inline/ARM/inline-fp.ll
@@ -7,7 +7,7 @@
; NOFP-DAG: single not inlined into test_single because too costly to inline (cost=125, threshold=75)
; NOFP-DAG: single not inlined into test_single because too costly to inline (cost=125, threshold=75)
; NOFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
-; NOFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
+; NOFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=15075)
; NOFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
; NOFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
; NOFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
@@ -16,20 +16,20 @@
; NOFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
; FULLFP-DAG: single inlined into test_single with (cost=0, threshold=75)
-; FULLFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
+; FULLFP-DAG: single inlined into test_single with (cost=0, threshold=15075)
; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
-; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
+; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=15075)
; FULLFP-DAG: double inlined into test_double with (cost=0, threshold=75)
-; FULLFP-DAG: double inlined into test_double with (cost=-15000, threshold=75)
+; FULLFP-DAG: double inlined into test_double with (cost=0, threshold=15075)
; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
; FULLFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
; FULLFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
; SINGLEFP-DAG: single inlined into test_single with (cost=0, threshold=75)
-; SINGLEFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
+; SINGLEFP-DAG: single inlined into test_single with (cost=0, threshold=15075)
; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
-; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
+; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=15075)
; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
; SINGLEFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
OpenPOWER on IntegriCloud