• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=2 -S < %s | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx10.14.0"
5
6; Check that these functions are not split. Outlined functions are called from a
7; basic block named codeRepl.
8
9; The cold region is too small to split.
10; CHECK-LABEL: @foo
11; CHECK-NOT: foo.cold.1
12define void @foo() {
13entry:
14  br i1 undef, label %if.then, label %if.end
15
16if.then:                                          ; preds = %entry
17  unreachable
18
19if.end:                                           ; preds = %entry
20  ret void
21}
22
23; The cold region is still too small to split.
24; CHECK-LABEL: @bar
25; CHECK-NOT: bar.cold.1
26define void @bar() {
27entry:
28  br i1 undef, label %if.then, label %if.end
29
30if.then:                                          ; preds = %entry
31  call void @sink()
32  ret void
33
34if.end:                                           ; preds = %entry
35  ret void
36}
37
38; Make sure we don't try to outline the entire function.
39; CHECK-LABEL: @fun
40; CHECK-NOT: fun.cold.1
41define void @fun() {
42entry:
43  br i1 undef, label %if.then, label %if.end
44
45if.then:                                          ; preds = %entry
46  call void @sink()
47  br label %if.end
48
49if.end:                                           ; preds = %entry
50  ret void
51}
52
53; Make sure we don't try to outline the entire function, especially when the
54; entry block is cold.
55; CHECK: define void @cold_entry_block() [[COLD_ATTR:#[0-9]+]]
56; CHECK-NOT: cold_entry_block.cold.1
57define void @cold_entry_block() {
58entry:
59  call void @sink()
60  ret void
61}
62
63; Do not split `noinline` functions.
64; CHECK-LABEL: @noinline_func
65; CHECK-NOT: noinline_func.cold.1
66define void @noinline_func() noinline {
67entry:
68  br i1 undef, label %if.then, label %if.end
69
70if.then:                                          ; preds = %entry
71  call void @sink()
72  br label %if.end
73
74if.end:                                           ; preds = %entry
75  ret void
76}
77
78; Do not split `alwaysinline` functions.
79; CHECK-LABEL: @alwaysinline_func
80; CHECK-NOT: alwaysinline_func.cold.1
81define void @alwaysinline_func() alwaysinline {
82entry:
83  br i1 undef, label %if.then, label %if.end
84
85if.then:                                          ; preds = %entry
86  call void @sink()
87  br label %if.end
88
89if.end:                                           ; preds = %entry
90  ret void
91}
92
93; Don't outline infinite loops.
94; CHECK-LABEL: @infinite_loop
95; CHECK-NOT: infinite_loop.cold.1
96define void @infinite_loop() {
97entry:
98  br label %loop
99
100loop:
101  call void @sink()
102  br label %loop
103}
104
105; Don't count debug intrinsics towards the outlining threshold.
106; CHECK-LABEL: @dont_count_debug_intrinsics
107; CHECK-NOT: dont_count_debug_intrinsics.cold.1
108define void @dont_count_debug_intrinsics(i32 %arg1) !dbg !6 {
109entry:
110  %var = add i32 0, 0, !dbg !11
111  br i1 undef, label %if.then, label %if.end
112
113if.then:                                          ; preds = %entry
114  ret void
115
116if.end:                                           ; preds = %entry
117  call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11
118  call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11
119  call void @sink()
120  ret void
121}
122
123; CHECK-LABEL: @sanitize_address
124; CHECK-NOT: sanitize_address.cold.1
125define void @sanitize_address() sanitize_address {
126entry:
127  br i1 undef, label %if.then, label %if.end
128
129if.then:                                          ; preds = %entry
130  call void @sink()
131  ret void
132
133if.end:                                           ; preds = %entry
134  ret void
135}
136
137; CHECK-LABEL: @sanitize_hwaddress
138; CHECK-NOT: sanitize_hwaddress.cold.1
139define void @sanitize_hwaddress() sanitize_hwaddress {
140entry:
141  br i1 undef, label %if.then, label %if.end
142
143if.then:                                          ; preds = %entry
144  call void @sink()
145  ret void
146
147if.end:                                           ; preds = %entry
148  ret void
149}
150
151; CHECK-LABEL: @sanitize_thread
152; CHECK-NOT: sanitize_thread.cold.1
153define void @sanitize_thread() sanitize_thread {
154entry:
155  br i1 undef, label %if.then, label %if.end
156
157if.then:                                          ; preds = %entry
158  call void @sink()
159  ret void
160
161if.end:                                           ; preds = %entry
162  ret void
163}
164
165; CHECK-LABEL: @sanitize_memory
166; CHECK-NOT: sanitize_memory.cold.1
167define void @sanitize_memory() sanitize_memory {
168entry:
169  br i1 undef, label %if.then, label %if.end
170
171if.then:                                          ; preds = %entry
172  call void @sink()
173  ret void
174
175if.end:                                           ; preds = %entry
176  ret void
177}
178
179declare void @llvm.trap() cold noreturn
180
181; CHECK-LABEL: @nosanitize_call
182; CHECK-NOT: nosanitize_call.cold.1
183define void @nosanitize_call() sanitize_memory {
184entry:
185  br i1 undef, label %if.then, label %if.end
186
187if.then:                                          ; preds = %entry
188  call void @llvm.trap(), !nosanitize !2
189  unreachable
190
191if.end:                                           ; preds = %entry
192  ret void
193}
194
195; CHECK: attributes [[COLD_ATTR]] = { {{.*}}cold
196
197declare void @llvm.dbg.value(metadata, metadata, metadata)
198
199declare void @sink() cold
200
201!llvm.dbg.cu = !{!0}
202!llvm.debugify = !{!3, !4}
203!llvm.module.flags = !{!5}
204
205!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
206!1 = !DIFile(filename: "<stdin>", directory: "/")
207!2 = !{}
208!3 = !{i32 7}
209!4 = !{i32 1}
210!5 = !{i32 2, !"Debug Info Version", i32 3}
211!6 = distinct !DISubprogram(name: "dont_count_debug_intrinsics", linkageName: "dont_count_debug_intrinsics", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
212!7 = !DISubroutineType(types: !2)
213!8 = !{!9}
214!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
215!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
216!11 = !DILocation(line: 1, column: 1, scope: !6)
217