| 1 |
;; Note that this needs new pass manager for now. Passing `-sample-profile-inline-replay` to legacy pass manager is a no-op. |
| 2 |
|
| 3 |
;; Check baseline inline decisions |
| 4 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=DEFAULT %s |
| 5 |
|
| 6 |
;; Check replay inline decisions |
| 7 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s |
| 8 |
|
| 9 |
;; Check baseline inline decisions with all callee counts missing |
| 10 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-missing.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=DEFAULT-NOINLINING -allow-empty %s |
| 11 |
|
| 12 |
;; Check replay inline decisions with all callee counts missing. The call sites should still be passed to the replay advisor and successfully get inlined as before |
| 13 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-missing.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-MISSING %s |
| 14 |
|
| 15 |
;; Check baseline inline decisions with high threshold |
| 16 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -profile-summary-hot-count=500000 -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=DEFAULT-NOINLINING -allow-empty %s |
| 17 |
|
| 18 |
;; Check replay inline decisions with high threshold. The call sites should still be passed to the replay advisor and successfully get inlined as before |
| 19 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -profile-summary-hot-count=500000 -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL -allow-empty %s |
| 20 |
|
| 21 |
;; Check Module scope Original fallback replay inline decisions |
| 22 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=Original -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s |
| 23 |
|
| 24 |
;; Check Module scope Original fallback replay inline with 'Line' format decisions |
| 25 |
;; The results are not different than REPLAY-MODULE-ORIGINAL, but the replay input only contains line numbers rather than line:column.discriminator |
| 26 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-line.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=Original -sample-profile-inline-replay-format=Line -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s |
| 27 |
|
| 28 |
;; Check Module scope Original fallback replay inline with 'LineColumn' format decisions |
| 29 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-linecolumn.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=Original -sample-profile-inline-replay-format=LineColumn -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s |
| 30 |
|
| 31 |
;; Check Module scope Original fallback replay inline with 'LineDiscriminator' format decisions |
| 32 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-linediscriminator.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=Original -sample-profile-inline-replay-format=LineDiscriminator -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s |
| 33 |
|
| 34 |
;; Check Module scope AlwaysInline fallback replay inline decisions |
| 35 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=AlwaysInline -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ALWAYS %s |
| 36 |
|
| 37 |
;; Check Module scope NeverInline fallback replay inline decisions |
| 38 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=Module -sample-profile-inline-replay-fallback=NeverInline -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-NEVER %s |
| 39 |
|
| 40 |
;; Check baseline inline decisions with "inline-topdown-inline-all.prof" which inlines all sites |
| 41 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-inline-all.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=DEFAULT-ALL %s |
| 42 |
|
| 43 |
;; Check function scope replay inline decisions with "inline-topdown-inline-all.prof" and "inline-topdown-function-scope.txt" which only contains: '_Z3sumii' inlined into 'main' |
| 44 |
;; 1. _Z3sumii is inlined into main, but all other inline candidates in main (e.g. _Z3subii) are not inlined |
| 45 |
;; 2. Inline decisions made in other functions match default sample inlining, in this case _Z3subii is inlined into _Z3sumii |
| 46 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-inline-all.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-function.txt -sample-profile-inline-replay-scope=Function -sample-profile-inline-replay-fallback=NeverInline -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ALL-FUNCTION-NEVER %s |
| 47 |
|
| 48 |
;; Function scope Original fallback |
| 49 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-inline-all.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-function.txt -sample-profile-inline-replay-scope=Function -sample-profile-inline-replay-fallback=Original -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ALL-FUNCTION-ORIGINAL %s |
| 50 |
|
| 51 |
;; Function scope AlwaysInline fallback |
| 52 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown-inline-all.prof -sample-profile-inline-replay=%S/Inputs/inline-replay-function.txt -sample-profile-inline-replay-scope=Function -sample-profile-inline-replay-fallback=AlwaysInline -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ALL-FUNCTION-ALWAYS %s |
| 53 |
|
| 54 |
;; Check behavior on non-existent replay file |
| 55 |
; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/non-existent-dummy.txt -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR %s |
| 56 |
|
| 57 |
;; Check scope inlining errors out on non <Module|Function> inputs |
| 58 |
; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-scope=function -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-SCOPE %s |
| 59 |
|
| 60 |
;; Check fallback inlining errors out on non <Original|AlwaysInline|NeverInline> inputs |
| 61 |
; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-fallback=original -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-FALLBACK %s |
| 62 |
|
| 63 |
;; Check format inlining errors out on non <Line|LineColumn|LineDiscriminator|LineColumnDiscriminator> inputs |
| 64 |
; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-inline-replay-format=line -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-FORMAT %s |
| 65 |
|
| 66 |
|
| 67 |
; DEFAULT: '_Z3sumii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 68 |
; DEFAULT: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost={{[-0-9]+}} |
| 69 |
; DEFAULT-NOT: '_Z3subii' inlined into 'main' |
| 70 |
|
| 71 |
; REPLAY-MODULE-MISSING: '_Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 72 |
; REPLAY-MODULE-MISSING-NOT: inlined into |
| 73 |
|
| 74 |
; REPLAY-MODULE-ORIGINAL: '_Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 75 |
; REPLAY-MODULE-ORIGINAL: '_Z3subii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 76 |
|
| 77 |
; REPLAY-MODULE-ALWAYS: '_Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 78 |
; REPLAY-MODULE-ALWAYS: '_Z3subii' inlined into 'main' to match profiling context with (cost=always) |
| 79 |
|
| 80 |
; REPLAY-MODULE-NEVER: '_Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 81 |
; REPLAY-MODULE-NEVER-NOT: '_Z3subii' inlined into 'main' |
| 82 |
|
| 83 |
; DEFAULT-NOINLINING-NOT: inlined into |
| 84 |
|
| 85 |
; DEFAULT-ALL: '_Z3sumii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 86 |
; DEFAULT-ALL: '_Z3subii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 87 |
; DEFAULT-ALL: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost={{[-0-9]+}} |
| 88 |
|
| 89 |
; REPLAY-ALL-FUNCTION-NEVER: _Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 90 |
; REPLAY-ALL-FUNCTION-NEVER-NOT: '_Z3subii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 91 |
; REPLAY-ALL-FUNCTION-NEVER: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost={{[-0-9]+}} |
| 92 |
|
| 93 |
; REPLAY-ALL-FUNCTION-ORIGINAL: _Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 94 |
; REPLAY-ALL-FUNCTION-ORIGINAL: '_Z3subii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}} |
| 95 |
; REPLAY-ALL-FUNCTION-ORIGINAL: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost={{[-0-9]+}} |
| 96 |
|
| 97 |
; REPLAY-ALL-FUNCTION-ALWAYS: _Z3sumii' inlined into 'main' to match profiling context with (cost=always) |
| 98 |
; REPLAY-ALL-FUNCTION-ALWAYS: '_Z3subii' inlined into 'main' to match profiling context with (cost=always) |
| 99 |
; REPLAY-ALL-FUNCTION-ALWAYS: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost={{[-0-9]+}} |
| 100 |
|
| 101 |
; REPLAY-ERROR: error: Could not open remarks file: |
| 102 |
; REPLAY-ERROR-SCOPE: for the --sample-profile-inline-replay-scope option: Cannot find option named 'function'! |
| 103 |
; REPLAY-ERROR-FALLBACK: for the --sample-profile-inline-replay-fallback option: Cannot find option named 'original'! |
| 104 |
; REPLAY-ERROR-FORMAT: for the --sample-profile-inline-replay-format option: Cannot find option named 'line'! |
| 105 |
|
| 106 |
@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 |
| 107 |
|
| 108 |
define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 { |
| 109 |
entry: |
| 110 |
%x.addr = alloca i32, align 4 |
| 111 |
%y.addr = alloca i32, align 4 |
| 112 |
store i32 %x, ptr %x.addr, align 4 |
| 113 |
store i32 %y, ptr %y.addr, align 4 |
| 114 |
%tmp = load i32, ptr %x.addr, align 4, !dbg !8 |
| 115 |
%tmp1 = load i32, ptr %y.addr, align 4, !dbg !8 |
| 116 |
%add = add nsw i32 %tmp, %tmp1, !dbg !8 |
| 117 |
%tmp2 = load i32, ptr %x.addr, align 4, !dbg !8 |
| 118 |
%tmp3 = load i32, ptr %y.addr, align 4, !dbg !8 |
| 119 |
%call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !8 |
| 120 |
ret i32 %add, !dbg !8 |
| 121 |
} |
| 122 |
|
| 123 |
define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 { |
| 124 |
entry: |
| 125 |
%x.addr = alloca i32, align 4 |
| 126 |
%y.addr = alloca i32, align 4 |
| 127 |
store i32 %x, ptr %x.addr, align 4 |
| 128 |
store i32 %y, ptr %y.addr, align 4 |
| 129 |
%tmp = load i32, ptr %x.addr, align 4, !dbg !10 |
| 130 |
%tmp1 = load i32, ptr %y.addr, align 4, !dbg !10 |
| 131 |
%add = sub nsw i32 %tmp, %tmp1, !dbg !10 |
| 132 |
ret i32 %add, !dbg !11 |
| 133 |
} |
| 134 |
|
| 135 |
define i32 @main() #0 !dbg !12 { |
| 136 |
entry: |
| 137 |
%retval = alloca i32, align 4 |
| 138 |
%s = alloca i32, align 4 |
| 139 |
%i = alloca i32, align 4 |
| 140 |
store i32 0, ptr %retval |
| 141 |
store i32 0, ptr %i, align 4, !dbg !13 |
| 142 |
br label %while.cond, !dbg !14 |
| 143 |
|
| 144 |
while.cond: ; preds = %if.end, %entry |
| 145 |
%tmp = load i32, ptr %i, align 4, !dbg !15 |
| 146 |
%inc = add nsw i32 %tmp, 1, !dbg !15 |
| 147 |
store i32 %inc, ptr %i, align 4, !dbg !15 |
| 148 |
%cmp = icmp slt i32 %tmp, 400000000, !dbg !15 |
| 149 |
br i1 %cmp, label %while.body, label %while.end, !dbg !15 |
| 150 |
|
| 151 |
while.body: ; preds = %while.cond |
| 152 |
%tmp1 = load i32, ptr %i, align 4, !dbg !17 |
| 153 |
%cmp1 = icmp ne i32 %tmp1, 100, !dbg !17 |
| 154 |
br i1 %cmp1, label %if.then, label %if.else, !dbg !17 |
| 155 |
|
| 156 |
if.then: ; preds = %while.body |
| 157 |
%tmp2 = load i32, ptr %i, align 4, !dbg !19 |
| 158 |
%tmp3 = load i32, ptr %s, align 4, !dbg !19 |
| 159 |
%call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !19 |
| 160 |
store i32 %call, ptr %s, align 4, !dbg !19 |
| 161 |
br label %if.end, !dbg !19 |
| 162 |
|
| 163 |
if.else: ; preds = %while.body |
| 164 |
store i32 30, ptr %s, align 4, !dbg !21 |
| 165 |
br label %if.end |
| 166 |
|
| 167 |
if.end: ; preds = %if.else, %if.then |
| 168 |
br label %while.cond, !dbg !23 |
| 169 |
|
| 170 |
while.end: ; preds = %while.cond |
| 171 |
%tmp4 = load i32, ptr %s, align 4, !dbg !25 |
| 172 |
%call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %tmp4), !dbg !25 |
| 173 |
ret i32 0, !dbg !26 |
| 174 |
} |
| 175 |
|
| 176 |
declare i32 @printf(ptr, ...) |
| 177 |
|
| 178 |
attributes #0 = { "use-sample-profile" } |
| 179 |
|
| 180 |
!llvm.dbg.cu = !{!0} |
| 181 |
!llvm.module.flags = !{!3, !4} |
| 182 |
!llvm.ident = !{!5} |
| 183 |
|
| 184 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
| 185 |
!1 = !DIFile(filename: "calls.cc", directory: ".") |
| 186 |
!2 = !{} |
| 187 |
!3 = !{i32 2, !"Dwarf Version", i32 4} |
| 188 |
!4 = !{i32 1, !"Debug Info Version", i32 3} |
| 189 |
!5 = !{!"clang version 3.5 "} |
| 190 |
!6 = distinct !DISubprogram(name: "sum", linkageName: "_Z3sumii", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 191 |
!7 = !DISubroutineType(types: !2) |
| 192 |
!8 = !DILocation(line: 4, scope: !6) |
| 193 |
!9 = distinct !DISubprogram(name: "sub", linkageName: "_Z3subii", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 194 |
!10 = !DILocation(line: 20, scope: !9) |
| 195 |
!11 = !DILocation(line: 21, scope: !9) |
| 196 |
!12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 197 |
!13 = !DILocation(line: 8, scope: !12) |
| 198 |
!14 = !DILocation(line: 9, scope: !12) |
| 199 |
!15 = !DILocation(line: 9, scope: !16) |
| 200 |
!16 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 2) |
| 201 |
!17 = !DILocation(line: 10, scope: !18) |
| 202 |
!18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10) |
| 203 |
!19 = !DILocation(line: 10, scope: !20) |
| 204 |
!20 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 2) |
| 205 |
!21 = !DILocation(line: 10, scope: !22) |
| 206 |
!22 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 4) |
| 207 |
!23 = !DILocation(line: 10, scope: !24) |
| 208 |
!24 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 6) |
| 209 |
!25 = !DILocation(line: 11, scope: !12) |
| 210 |
!26 = !DILocation(line: 12, scope: !12) |