diff options
| author | James Molloy <james.molloy@arm.com> | 2016-11-14 11:14:41 +0000 |
|---|---|---|
| committer | James Molloy <james.molloy@arm.com> | 2016-11-14 11:14:41 +0000 |
| commit | 6df8f27c95a514b19476a0e6f66107575281f158 (patch) | |
| tree | fb872b100d4b398072a9e6017a71de557a9b6024 /llvm/lib/Analysis | |
| parent | 059680f3f0c1b755b04425562efdf7284ff9ac70 (diff) | |
| download | bcm5719-llvm-6df8f27c95a514b19476a0e6f66107575281f158.tar.gz bcm5719-llvm-6df8f27c95a514b19476a0e6f66107575281f158.zip | |
[InlineCost] Remove skew when calculating call costs
When calculating the cost of a call instruction we were applying a heuristic penalty as well as the cost of the instruction itself.
However, when calculating the benefit from inlining we weren't discounting the equivalent penalty for the call instruction that would be removed! This caused skew in the calculation and meant we wouldn't inline in the following, trivial case:
int g() {
h();
}
int f() {
g();
}
llvm-svn: 286814
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index d820069e6ce..6c3525fad4e 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1255,7 +1255,9 @@ bool CallAnalyzer::analyzeCall(CallSite CS) { Cost -= InlineConstants::InstrCost; } } - + // The call instruction also disappears after inlining. + Cost -= InlineConstants::InstrCost + InlineConstants::CallPenalty; + // If there is only one call of the function, and it has internal linkage, // the cost of inlining it drops dramatically. bool OnlyOneCallAndLocalLinkage = |

