-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Remarks][2/2] Expand remarks hotness threshold option support in mor…
…e tools This is the #2 of 2 changes that make remarks hotness threshold option available in more tools. The changes also allow the threshold to sync with hotness threshold from profile summary with special value 'auto'. This change expands remarks hotness threshold option -fdiagnostics-hotness-threshold in clang and *-remarks-hotness-threshold in other tools to utilize hotness threshold from profile summary. Remarks hotness filtering relies on several driver options. Table below lists how different options are correlated and affect final remarks outputs: | profile | hotness | threshold | remarks printed | |---------|---------|-----------|-----------------| | No | No | No | All | | No | No | Yes | None | | No | Yes | No | All | | No | Yes | Yes | None | | Yes | No | No | All | | Yes | No | Yes | None | | Yes | Yes | No | All | | Yes | Yes | Yes | >=threshold | In the presence of profile summary, it is often more desirable to directly use the hotness threshold from profile summary. The new argument value 'auto' indicates threshold will be synced with hotness threshold from profile summary during compilation. The "auto" threshold relies on the availability of profile summary. In case of missing such information, no remarks will be generated. Differential Revision: https://reviews.llvm.org/D85808
- Loading branch information
Showing
18 changed files
with
313 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_Z7callee1v:600:600 | ||
1: 600 | ||
_Z7callee2v:1:1 | ||
1: 1 | ||
_Z7caller1v:400:400 | ||
1: 400 | ||
_Z7caller2v:1:1 | ||
1: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Without hotness threshold, print both hot and cold remarks. | ||
// RUN: %clang_cc1 -triple x86_64-linux %s -emit-llvm-only -O3 \ | ||
// RUN: -fprofile-sample-use=%S/Inputs/remarks-hotness.prof \ | ||
// RUN: -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline \ | ||
// RUN: -fexperimental-new-pass-manager -fdiagnostics-show-hotness 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=REMARKS %s | ||
|
||
// With auto hotness threshold, only print hot remarks. | ||
// RUN: %clang_cc1 -triple x86_64-linux %s -emit-llvm-only -O3 \ | ||
// RUN: -fprofile-sample-use=%S/Inputs/remarks-hotness.prof \ | ||
// RUN: -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline \ | ||
// RUN: -fexperimental-new-pass-manager -fdiagnostics-show-hotness \ | ||
// RUN: -fdiagnostics-hotness-threshold=auto 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOT_CALL %s | ||
|
||
int callee1() { | ||
return 1; | ||
} | ||
|
||
__attribute__((noinline)) int callee2() { | ||
return 2; | ||
} | ||
|
||
// REMARKS: _Z7callee1v inlined into _Z7caller1v | ||
// HOT_CALL: _Z7callee1v inlined into _Z7caller1v | ||
int caller1() { | ||
return callee1(); | ||
} | ||
|
||
// REMARKS: _Z7callee2v not inlined into _Z7caller2v | ||
// HOT_CALL-NOT: _Z7callee2v not inlined into _Z7caller2v | ||
int caller2() { | ||
return callee2(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
;; This test verifies 'auto' hotness threshold when profile summary is available. | ||
;; | ||
;; new PM | ||
; RUN: rm -f %t.yaml %t.hot.yaml | ||
; RUN: opt < %s --disable-output --enable-new-pm \ | ||
; RUN: --passes='inline' \ | ||
; RUN: --pass-remarks-output=%t.yaml --pass-remarks-filter='inline' \ | ||
; RUN: --pass-remarks-with-hotness | ||
; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml | ||
; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml | ||
|
||
;; test 'auto' threshold | ||
; RUN: opt < %s --disable-output --enable-new-pm \ | ||
; RUN: --passes='module(print-profile-summary,cgscc(inline))' \ | ||
; RUN: --pass-remarks-output=%t.hot.yaml --pass-remarks-filter='inline' \ | ||
; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto 2>&1 | FileCheck %s | ||
; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml | ||
; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml | ||
|
||
; RUN: opt < %s --disable-output --enable-new-pm \ | ||
; RUN: --passes='module(print-profile-summary,cgscc(inline))' \ | ||
; RUN: --pass-remarks=inline --pass-remarks-missed=inline --pass-remarks-analysis=inline \ | ||
; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto 2>&1 | FileCheck %s -check-prefix=CHECK-RPASS | ||
|
||
; YAML-PASS: --- !Passed | ||
; YAML-PASS-NEXT: Pass: inline | ||
; YAML-PASS-NEXT: Name: Inlined | ||
; YAML-PASS-NEXT: Function: caller1 | ||
; YAML-PASS-NEXT: Hotness: 400 | ||
|
||
; YAML-MISS: --- !Missed | ||
; YAML-MISS-NEXT: Pass: inline | ||
; YAML-MISS-NEXT: Name: NeverInline | ||
; YAML-MISS-NEXT: Function: caller2 | ||
; YAML-MISS-NEXT: Hotness: 1 | ||
|
||
; CHECK-RPASS: callee1 inlined into caller1 with (cost=-30, threshold=4500) (hotness: 400) | ||
; CHECK-RPASS-NOT: callee2 not inlined into caller2 because it should never be inlined (cost=never): noinline function attribute (hotness: 1) | ||
|
||
define void @callee1() !prof !20 { | ||
; CHECK: callee1 :hot | ||
entry: | ||
ret void | ||
} | ||
|
||
; Function Attrs: noinline | ||
define void @callee2() noinline !prof !21 { | ||
; CHECK: callee2 :cold | ||
entry: | ||
ret void | ||
} | ||
|
||
define void @caller1() !prof !20 { | ||
; CHECK: caller1 :hot | ||
entry: | ||
call void @callee1() | ||
ret void | ||
} | ||
|
||
define void @caller2() !prof !21 { | ||
; CHECK: caller2 :cold | ||
entry: | ||
call void @callee2() | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!1} | ||
!20 = !{!"function_entry_count", i64 400} | ||
!21 = !{!"function_entry_count", i64 1} | ||
|
||
!1 = !{i32 1, !"ProfileSummary", !2} | ||
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} | ||
!3 = !{!"ProfileFormat", !"InstrProf"} | ||
!4 = !{!"TotalCount", i64 10000} | ||
!5 = !{!"MaxCount", i64 10} | ||
!6 = !{!"MaxInternalCount", i64 1} | ||
!7 = !{!"MaxFunctionCount", i64 1000} | ||
!8 = !{!"NumCounts", i64 3} | ||
!9 = !{!"NumFunctions", i64 3} | ||
!10 = !{!"DetailedSummary", !11} | ||
!11 = !{!12, !13, !14} | ||
!12 = !{i32 10000, i64 100, i32 1} | ||
!13 = !{i32 999000, i64 100, i32 1} | ||
!14 = !{i32 999999, i64 1, i32 2} | ||
|
Oops, something went wrong.