1 ;; Note that this needs new pass manager for now. Passing `-cgscc-inline-replay` to legacy pass manager is a no-op.
3 ;; Check baseline inline decisions
4 ; RUN: opt < %s -passes=inline -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=DEFAULT %s
6 ;; Check Module scope Original fallback replay inline decisions
7 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-scope=Module -cgscc-inline-replay-fallback=Original -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s
9 ;; Check Module scope Original fallback replay inline with 'Line' format decisions
10 ;; The results are not different than REPLAY-MODULE-ORIGINAL, but the replay input only contains line numbers rather than line:column.discriminator
11 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay-line.txt -cgscc-inline-replay-scope=Module -cgscc-inline-replay-fallback=Original -cgscc-inline-replay-format=Line -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ORIGINAL %s
13 ;; Check Module scope AlwaysInline fallback replay inline decisions
14 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-scope=Module -cgscc-inline-replay-fallback=AlwaysInline -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-ALWAYS %s
16 ;; Check Module scope NeverInline fallback replay inline decisions
17 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-scope=Module -cgscc-inline-replay-fallback=NeverInline -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-MODULE-NEVER %s
19 ;; Check Function scope Original fallback replay inline decisions
20 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay-function.txt -cgscc-inline-replay-scope=Function -cgscc-inline-replay-fallback=Original -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-FUNCTION-ORIGINAL %s
22 ;; Check Function scope AlwaysInline fallback replay inline decisions
23 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay-function.txt -cgscc-inline-replay-scope=Function -cgscc-inline-replay-fallback=AlwaysInline -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-FUNCTION-ALWAYS %s
25 ;; Check Function scope NeverInline fallback replay inline decisions
26 ; RUN: opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay-function.txt -cgscc-inline-replay-scope=Function -cgscc-inline-replay-fallback=NeverInline -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-FUNCTION-NEVER %s
28 ;; Check behavior on non-existent replay file
29 ; RUN: not opt < %s -passes=inline -cgscc-inline-replay=%S/non-existent-dummy.txt -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR %s
31 ;; Check scope inlining errors out on non <Module|Function> inputs
32 ; RUN: not opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-scope=function -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-SCOPE %s
34 ;; Check fallback inlining errors out on non <Original|AlwaysInline|NeverInline> inputs
35 ; RUN: not opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-fallback=original -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-FALLBACK %s
37 ;; Check format inlining errors out on non <Line|AlwayLineColumnsInline|LineDiscriminator|LineColumnDiscriminator> inputs
38 ; RUN: not opt < %s -passes=inline -cgscc-inline-replay=%S/Inputs/cgscc-inline-replay.txt -cgscc-inline-replay-format=line -pass-remarks=inline --disable-output 2>&1 | FileCheck -check-prefix=REPLAY-ERROR-FORMAT %s
40 ; DEFAULT: '_Z3subii' inlined into '_Z3sumii' with (cost={{[-0-9]+}}
41 ; DEFAULT: '_Z3sumii' inlined into 'main' with (cost={{[-0-9]+}}
42 ; DEFAULT-NOT: '_Z3subii' inlined into 'main'
44 ; REPLAY-MODULE-ORIGINAL: '_Z3sumii' inlined into 'main' with (cost=always)
45 ; REPLAY-MODULE-ORIGINAL: '_Z3subii' inlined into 'main' with (cost={{[-0-9]+}}
47 ; REPLAY-MODULE-ALWAYS: '_Z3sumii' inlined into 'main' with (cost=always)
48 ; REPLAY-MODULE-ALWAYS: '_Z3subii' inlined into 'main' with (cost=always)
50 ; REPLAY-MODULE-NEVER: '_Z3sumii' inlined into 'main' with (cost=always)
51 ; REPLAY-MODULE-NEVER-NOT: '_Z3subii' inlined into 'main'
53 ; REPLAY-FUNCTION-ORIGINAL: '_Z3subii' inlined into '_Z3sumii' with (cost={{[-0-9]+}}
54 ; REPLAY-FUNCTION-ORIGINAL: '_Z3sumii' inlined into 'main' with (cost={{[-0-9]+}}
56 ; REPLAY-FUNCTION-ALWAYS: '_Z3subii' inlined into '_Z3sumii' with (cost={{[-0-9]+}}
57 ; REPLAY-FUNCTION-ALWAYS: '_Z3sumii' inlined into 'main' with (cost=always)
59 ; REPLAY-FUNCTION-NEVER: '_Z3subii' inlined into '_Z3sumii' with (cost={{[-0-9]+}}
60 ; REPLAY-FUNCTION-NEVER-NOT: '_Z3sumii' inlined into 'main'
62 ; REPLAY-ERROR: error: Could not open remarks file:
63 ; REPLAY-ERROR-SCOPE: for the --cgscc-inline-replay-scope option: Cannot find option named 'function'!
64 ; REPLAY-ERROR-FALLBACK: for the --cgscc-inline-replay-fallback option: Cannot find option named 'original'!
65 ; REPLAY-ERROR-FORMAT: for the --cgscc-inline-replay-format option: Cannot find option named 'line'!
67 @.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1
69 define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 {
71 %x.addr = alloca i32, align 4
72 %y.addr = alloca i32, align 4
73 store i32 %x, ptr %x.addr, align 4
74 store i32 %y, ptr %y.addr, align 4
75 %tmp = load i32, ptr %x.addr, align 4, !dbg !8
76 %tmp1 = load i32, ptr %y.addr, align 4, !dbg !8
77 %add = add nsw i32 %tmp, %tmp1, !dbg !8
78 %tmp2 = load i32, ptr %x.addr, align 4, !dbg !8
79 %tmp3 = load i32, ptr %y.addr, align 4, !dbg !8
80 %call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !8
84 define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 {
86 %x.addr = alloca i32, align 4
87 %y.addr = alloca i32, align 4
88 store i32 %x, ptr %x.addr, align 4
89 store i32 %y, ptr %y.addr, align 4
90 %tmp = load i32, ptr %x.addr, align 4, !dbg !10
91 %tmp1 = load i32, ptr %y.addr, align 4, !dbg !10
92 %add = sub nsw i32 %tmp, %tmp1, !dbg !10
93 ret i32 %add, !dbg !11
96 define i32 @main() #0 !dbg !12 {
98 %retval = alloca i32, align 4
99 %s = alloca i32, align 4
100 %i = alloca i32, align 4
101 store i32 0, ptr %retval
102 store i32 0, ptr %i, align 4, !dbg !13
103 br label %while.cond, !dbg !14
105 while.cond: ; preds = %if.end, %entry
106 %tmp = load i32, ptr %i, align 4, !dbg !15
107 %inc = add nsw i32 %tmp, 1, !dbg !15
108 store i32 %inc, ptr %i, align 4, !dbg !15
109 %cmp = icmp slt i32 %tmp, 400000000, !dbg !15
110 br i1 %cmp, label %while.body, label %while.end, !dbg !15
112 while.body: ; preds = %while.cond
113 %tmp1 = load i32, ptr %i, align 4, !dbg !17
114 %cmp1 = icmp ne i32 %tmp1, 100, !dbg !17
115 br i1 %cmp1, label %if.then, label %if.else, !dbg !17
117 if.then: ; preds = %while.body
118 %tmp2 = load i32, ptr %i, align 4, !dbg !19
119 %tmp3 = load i32, ptr %s, align 4, !dbg !19
120 %call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !19
121 store i32 %call, ptr %s, align 4, !dbg !19
122 br label %if.end, !dbg !19
124 if.else: ; preds = %while.body
125 store i32 30, ptr %s, align 4, !dbg !21
128 if.end: ; preds = %if.else, %if.then
129 br label %while.cond, !dbg !23
131 while.end: ; preds = %while.cond
132 %tmp4 = load i32, ptr %s, align 4, !dbg !25
133 %call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %tmp4), !dbg !25
137 declare i32 @printf(ptr, ...)
139 attributes #0 = { "use-sample-profile" }
142 !llvm.module.flags = !{!3, !4}
145 !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)
146 !1 = !DIFile(filename: "calls.cc", directory: ".")
148 !3 = !{i32 2, !"Dwarf Version", i32 4}
149 !4 = !{i32 1, !"Debug Info Version", i32 3}
150 !5 = !{!"clang version 3.5 "}
151 !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)
152 !7 = !DISubroutineType(types: !2)
153 !8 = !DILocation(line: 4, scope: !6)
154 !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)
155 !10 = !DILocation(line: 20, scope: !9)
156 !11 = !DILocation(line: 21, scope: !9)
157 !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)
158 !13 = !DILocation(line: 8, scope: !12)
159 !14 = !DILocation(line: 9, scope: !12)
160 !15 = !DILocation(line: 9, scope: !16)
161 !16 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 2)
162 !17 = !DILocation(line: 10, scope: !18)
163 !18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10)
164 !19 = !DILocation(line: 10, scope: !20)
165 !20 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 2)
166 !21 = !DILocation(line: 10, scope: !22)
167 !22 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 4)
168 !23 = !DILocation(line: 10, scope: !24)
169 !24 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 6)
170 !25 = !DILocation(line: 11, scope: !12)
171 !26 = !DILocation(line: 12, scope: !12)