| 1 |
;; This test verifies 'auto' hotness threshold when profile file is provided. |
| 2 |
;; |
| 3 |
;; new PM |
| 4 |
; RUN: rm -f %t.yaml %t.hot.yaml |
| 5 |
; RUN: opt %s --passes='sample-profile,cgscc(inline)' \ |
| 6 |
; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \ |
| 7 |
; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \ |
| 8 |
; RUN: -pass-remarks-with-hotness --disable-output |
| 9 |
; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml |
| 10 |
; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml |
| 11 |
|
| 12 |
;; test 'auto' threshold |
| 13 |
; RUN: opt %s --passes='sample-profile,cgscc(inline)' \ |
| 14 |
; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \ |
| 15 |
; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \ |
| 16 |
; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output |
| 17 |
; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml |
| 18 |
; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml |
| 19 |
|
| 20 |
; RUN: opt %s --passes='sample-profile,cgscc(inline)' \ |
| 21 |
; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \ |
| 22 |
; RUN: -S --pass-remarks=inline --pass-remarks-missed=inline --pass-remarks-analysis=inline \ |
| 23 |
; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-RPASS |
| 24 |
|
| 25 |
; YAML-PASS: --- !Passed |
| 26 |
; YAML-PASS-NEXT: Pass: inline |
| 27 |
; YAML-PASS-NEXT: Name: Inlined |
| 28 |
; YAML-PASS-NEXT: DebugLoc: { File: remarks-hotness.cpp, Line: 10, Column: 10 } |
| 29 |
; YAML-PASS-NEXT: Function: _Z7caller1v |
| 30 |
; YAML-PASS-NEXT: Hotness: 401 |
| 31 |
|
| 32 |
; YAML-MISS: --- !Missed |
| 33 |
; YAML-MISS-NEXT: Pass: inline |
| 34 |
; YAML-MISS-NEXT: Name: NeverInline |
| 35 |
; YAML-MISS-NEXT: DebugLoc: { File: remarks-hotness.cpp, Line: 14, Column: 10 } |
| 36 |
; YAML-MISS-NEXT: Function: _Z7caller2v |
| 37 |
; YAML-MISS-NEXT: Hotness: 2 |
| 38 |
|
| 39 |
; CHECK-RPASS: '_Z7callee1v' inlined into '_Z7caller1v' with (cost=-30, threshold=4500) at callsite _Z7caller1v:1:10; (hotness: 401) |
| 40 |
; CHECK-RPASS-NOT: '_Z7callee2v' not inlined into '_Z7caller2v' because it should never be inlined (cost=never): noinline function attribute (hotness: 2) |
| 41 |
|
| 42 |
; ModuleID = 'remarks-hotness.cpp' |
| 43 |
source_filename = "remarks-hotness.cpp" |
| 44 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 45 |
target triple = "x86_64-unknown-linux-gnu" |
| 46 |
|
| 47 |
; Function Attrs: use-sample-profile |
| 48 |
define dso_local i32 @_Z7callee1v() #0 !dbg !7 { |
| 49 |
ret i32 1, !dbg !11 |
| 50 |
} |
| 51 |
|
| 52 |
; Function Attrs: noinline nounwind uwtable use-sample-profile |
| 53 |
define dso_local i32 @_Z7callee2v() #1 !dbg !12 { |
| 54 |
ret i32 2, !dbg !13 |
| 55 |
} |
| 56 |
|
| 57 |
; Function Attrs: use-sample-profile |
| 58 |
define dso_local i32 @_Z7caller1v() #0 !dbg !14 { |
| 59 |
%1 = call i32 @_Z7callee1v(), !dbg !15 |
| 60 |
ret i32 %1, !dbg !16 |
| 61 |
} |
| 62 |
|
| 63 |
; Function Attrs: use-sample-profile |
| 64 |
define dso_local i32 @_Z7caller2v() #0 !dbg !17 { |
| 65 |
%1 = call i32 @_Z7callee2v(), !dbg !18 |
| 66 |
ret i32 %1, !dbg !19 |
| 67 |
} |
| 68 |
|
| 69 |
attributes #0 = { "use-sample-profile" } |
| 70 |
attributes #1 = { noinline nounwind uwtable "use-sample-profile" } |
| 71 |
|
| 72 |
!llvm.dbg.cu = !{!0} |
| 73 |
!llvm.module.flags = !{!3, !4, !5} |
| 74 |
!llvm.ident = !{!6} |
| 75 |
|
| 76 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None) |
| 77 |
!1 = !DIFile(filename: "remarks-hotness.cpp", directory: ".") |
| 78 |
!2 = !{} |
| 79 |
!3 = !{i32 7, !"Dwarf Version", i32 4} |
| 80 |
!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 81 |
!5 = !{i32 1, !"wchar_size", i32 4} |
| 82 |
!6 = !{!"clang version 11.0.0"} |
| 83 |
!7 = distinct !DISubprogram(name: "callee1", linkageName: "_Z7callee1v", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 84 |
!8 = !DISubroutineType(types: !9) |
| 85 |
!9 = !{!10} |
| 86 |
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 87 |
!11 = !DILocation(line: 2, column: 3, scope: !7) |
| 88 |
!12 = distinct !DISubprogram(name: "callee2", linkageName: "_Z7callee2v", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 89 |
!13 = !DILocation(line: 6, column: 3, scope: !12) |
| 90 |
!14 = distinct !DISubprogram(name: "caller1", linkageName: "_Z7caller1v", scope: !1, file: !1, line: 9, type: !8, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 91 |
!15 = !DILocation(line: 10, column: 10, scope: !14) |
| 92 |
!16 = !DILocation(line: 10, column: 3, scope: !14) |
| 93 |
!17 = distinct !DISubprogram(name: "caller2", linkageName: "_Z7caller2v", scope: !1, file: !1, line: 13, type: !8, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 94 |
!18 = !DILocation(line: 14, column: 10, scope: !17) |
| 95 |
!19 = !DILocation(line: 14, column: 3, scope: !17) |