1 ; RUN: opt -passes=hotcoldsplit -hotcoldsplit-threshold=2 -S < %s | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.14.0"
6 ; Check that these functions are not split. Outlined functions are called from a
7 ; basic block named codeRepl.
9 ; The cold region is too small to split.
11 ; CHECK-NOT: foo.cold.1
14 br i1 undef, label %if.then, label %if.end
16 if.then: ; preds = %entry
19 if.end: ; preds = %entry
23 ; The cold region is still too small to split.
25 ; CHECK-NOT: bar.cold.1
28 br i1 undef, label %if.then, label %if.end
30 if.then: ; preds = %entry
34 if.end: ; preds = %entry
38 ; Make sure we don't try to outline the entire function.
40 ; CHECK-NOT: fun.cold.1
43 br i1 undef, label %if.then, label %if.end
45 if.then: ; preds = %entry
49 if.end: ; preds = %entry
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
57 define void @cold_entry_block() {
63 ; Do not split `noinline` functions.
64 ; CHECK-LABEL: @noinline_func
65 ; CHECK-NOT: noinline_func.cold.1
66 define void @noinline_func() noinline {
68 br i1 undef, label %if.then, label %if.end
70 if.then: ; preds = %entry
74 if.end: ; preds = %entry
78 ; Do not split `alwaysinline` functions.
79 ; CHECK-LABEL: @alwaysinline_func
80 ; CHECK-NOT: alwaysinline_func.cold.1
81 define void @alwaysinline_func() alwaysinline {
83 br i1 undef, label %if.then, label %if.end
85 if.then: ; preds = %entry
89 if.end: ; preds = %entry
93 ; Don't outline infinite loops.
94 ; CHECK-LABEL: @infinite_loop
95 ; CHECK-NOT: infinite_loop.cold.1
96 define void @infinite_loop() {
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
108 define void @dont_count_debug_intrinsics(i32 %arg1) !dbg !6 {
110 %var = add i32 0, 0, !dbg !11
111 br i1 undef, label %if.then, label %if.end
113 if.then: ; preds = %entry
116 if.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
123 ; CHECK-LABEL: @sanitize_address
124 ; CHECK-NOT: sanitize_address.cold.1
125 define void @sanitize_address() sanitize_address {
127 br i1 undef, label %if.then, label %if.end
129 if.then: ; preds = %entry
133 if.end: ; preds = %entry
137 ; CHECK-LABEL: @sanitize_hwaddress
138 ; CHECK-NOT: sanitize_hwaddress.cold.1
139 define void @sanitize_hwaddress() sanitize_hwaddress {
141 br i1 undef, label %if.then, label %if.end
143 if.then: ; preds = %entry
147 if.end: ; preds = %entry
151 ; CHECK-LABEL: @sanitize_thread
152 ; CHECK-NOT: sanitize_thread.cold.1
153 define void @sanitize_thread() sanitize_thread {
155 br i1 undef, label %if.then, label %if.end
157 if.then: ; preds = %entry
161 if.end: ; preds = %entry
165 ; CHECK-LABEL: @sanitize_memory
166 ; CHECK-NOT: sanitize_memory.cold.1
167 define void @sanitize_memory() sanitize_memory {
169 br i1 undef, label %if.then, label %if.end
171 if.then: ; preds = %entry
175 if.end: ; preds = %entry
179 declare void @llvm.trap() cold noreturn
181 ; CHECK-LABEL: @nosanitize_call
182 ; CHECK-NOT: nosanitize_call.cold.1
183 define void @nosanitize_call() sanitize_memory {
185 br i1 undef, label %if.then, label %if.end
187 if.then: ; preds = %entry
188 call void @llvm.trap(), !nosanitize !2
191 if.end: ; preds = %entry
195 ; CHECK: attributes [[COLD_ATTR]] = { {{.*}}cold
197 declare void @llvm.dbg.value(metadata, metadata, metadata)
199 declare void @sink() cold
202 !llvm.debugify = !{!3, !4}
203 !llvm.module.flags = !{!5}
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: "/")
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)
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)