[PATCH] D33157: [Inliner] Do not mix callsite and callee hotness based updates.
Easwaran Raman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 17:20:19 PDT 2017
eraman created this revision.
Update threshold based on callee's hotness only when BFI is not available. Otherwise use only callsite's hotness.
https://reviews.llvm.org/D33157
Files:
lib/Analysis/InlineCost.cpp
test/Transforms/Inline/inline-hot-callee.ll
test/Transforms/Inline/inline-hot-callsite.ll
Index: test/Transforms/Inline/inline-hot-callsite.ll
===================================================================
--- test/Transforms/Inline/inline-hot-callsite.ll
+++ test/Transforms/Inline/inline-hot-callsite.ll
@@ -1,9 +1,9 @@
-; This tests that a hot callsite gets the (higher) inlinehint-threshold even without
-; without inline hints and gets inlined because the cost is less than
-; inlinehint-threshold. A cold callee with identical body does not get inlined because
-; cost exceeds the inline-threshold
+; This tests that a hot callsite gets the (higher) inlinehint-threshold even
+; without ; without inline hints and gets inlined because the cost is less than
+; inlinehint-threshold. A cold callee with identical body does not get inlined
+; because cost exceeds the inline-threshold. This test is relevant only when
+; the new pass manager is used.
-; RUN: opt < %s -inline -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
; Run this with the default O2 pipeline to test that profile summary analysis
Index: test/Transforms/Inline/inline-hot-callee.ll
===================================================================
--- test/Transforms/Inline/inline-hot-callee.ll
+++ test/Transforms/Inline/inline-hot-callee.ll
@@ -1,10 +1,10 @@
; RUN: opt < %s -inline -inline-threshold=0 -inlinehint-threshold=100 -S | FileCheck %s
-; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -inlinehint-threshold=100 -S | FileCheck %s
-; This tests that a hot callee gets the (higher) inlinehint-threshold even without
-; inline hints and gets inlined because the cost is less than inlinehint-threshold.
-; A cold callee with identical body does not get inlined because cost exceeds the
-; inline-threshold
+; This tests that a hot callee gets the (higher) inlinehint-threshold even
+; without inline hints and gets inlined because the cost is less than
+; inlinehint-threshold. A cold callee with identical body does not get inlined
+; because cost exceeds the inline-threshold. This test is relevant only when the
+; old pass manager is used.
define i32 @callee1(i32 %x) !prof !21 {
%x1 = add i32 %x, 1
Index: lib/Analysis/InlineCost.cpp
===================================================================
--- lib/Analysis/InlineCost.cpp
+++ lib/Analysis/InlineCost.cpp
@@ -669,21 +669,28 @@
Threshold = MaxIfValid(Threshold, Params.HintThreshold);
if (PSI) {
BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr;
- if (PSI->isHotCallSite(CS, CallerBFI)) {
- DEBUG(dbgs() << "Hot callsite.\n");
- Threshold = Params.HotCallSiteThreshold.getValue();
- } else if (PSI->isFunctionEntryHot(&Callee)) {
- DEBUG(dbgs() << "Hot callee.\n");
- // If callsite hotness can not be determined, we may still know
- // that the callee is hot and treat it as a weaker hint for threshold
- // increase.
- Threshold = MaxIfValid(Threshold, Params.HintThreshold);
- } else if (PSI->isColdCallSite(CS, CallerBFI)) {
- DEBUG(dbgs() << "Cold callsite.\n");
- Threshold = MinIfValid(Threshold, Params.ColdCallSiteThreshold);
- } else if (PSI->isFunctionEntryCold(&Callee)) {
- DEBUG(dbgs() << "Cold callee.\n");
- Threshold = MinIfValid(Threshold, Params.ColdThreshold);
+ // FIXME: After switching to the new passmanager, simplify the logic below
+ // by checking only the callsite hotness/coldness. The check for CallerBFI
+ // exists only because we do not have BFI available with the old PM.
+ if (CallerBFI) {
+ if (PSI->isHotCallSite(CS, CallerBFI)) {
+ DEBUG(dbgs() << "Hot callsite.\n");
+ Threshold = Params.HotCallSiteThreshold.getValue();
+ } else if (PSI->isColdCallSite(CS, CallerBFI)) {
+ DEBUG(dbgs() << "Cold callsite.\n");
+ Threshold = MinIfValid(Threshold, Params.ColdCallSiteThreshold);
+ }
+ } else {
+ if (PSI->isFunctionEntryHot(&Callee)) {
+ DEBUG(dbgs() << "Hot callee.\n");
+ // If callsite hotness can not be determined, we may still know
+ // that the callee is hot and treat it as a weaker hint for threshold
+ // increase.
+ Threshold = MaxIfValid(Threshold, Params.HintThreshold);
+ } else if (PSI->isFunctionEntryCold(&Callee)) {
+ DEBUG(dbgs() << "Cold callee.\n");
+ Threshold = MinIfValid(Threshold, Params.ColdThreshold);
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33157.98861.patch
Type: text/x-patch
Size: 4665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170513/0cf51ca2/attachment-0001.bin>
More information about the llvm-commits
mailing list