1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt < %s -passes='function(lower-allow-check)' -S | FileCheck %s --check-prefixes=NOPROFILE
3 ; RUN: opt < %s -passes='function(lower-allow-check)' -lower-allow-check-random-rate=0 -S | FileCheck %s --check-prefixes=NONE
4 ; RUN: opt < %s -passes='function(lower-allow-check)' -lower-allow-check-random-rate=1 -S | FileCheck %s --check-prefixes=ALL
5 ; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-percentile-cutoff-hot=990000 -S | FileCheck %s --check-prefixes=HOT99
6 ; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=HOT70
7 ; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-random-rate=0 -lower-allow-check-percentile-cutoff-hot=990000 -S | FileCheck %s --check-prefixes=NONE99
8 ; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-random-rate=1 -lower-allow-check-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=ALL70
10 target triple = "x86_64-pc-linux-gnu"
12 declare void @llvm.ubsantrap(i8 immarg)
13 declare i1 @llvm.allow.ubsan.check(i8 immarg)
15 define dso_local noundef i32 @simple(ptr noundef readonly %0) {
16 ; NOPROFILE-LABEL: define dso_local noundef i32 @simple(
17 ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) {
18 ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
19 ; NOPROFILE-NEXT: [[HOT:%.*]] = xor i1 true, true
20 ; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
21 ; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
23 ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22)
24 ; NOPROFILE-NEXT: unreachable
26 ; NOPROFILE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
27 ; NOPROFILE-NEXT: ret i32 [[TMP5]]
29 ; NONE-LABEL: define dso_local noundef i32 @simple(
30 ; NONE-SAME: ptr noundef readonly [[TMP0:%.*]]) {
31 ; NONE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
32 ; NONE-NEXT: [[HOT:%.*]] = xor i1 false, true
33 ; NONE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
34 ; NONE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
36 ; NONE-NEXT: tail call void @llvm.ubsantrap(i8 22)
37 ; NONE-NEXT: unreachable
39 ; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
40 ; NONE-NEXT: ret i32 [[TMP5]]
42 ; ALL-LABEL: define dso_local noundef i32 @simple(
43 ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) {
44 ; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
45 ; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
46 ; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
47 ; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
49 ; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
50 ; ALL-NEXT: unreachable
52 ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
53 ; ALL-NEXT: ret i32 [[TMP5]]
55 ; HOT99-LABEL: define dso_local noundef i32 @simple(
56 ; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) {
57 ; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
58 ; HOT99-NEXT: [[HOT:%.*]] = xor i1 true, true
59 ; HOT99-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
60 ; HOT99-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
62 ; HOT99-NEXT: tail call void @llvm.ubsantrap(i8 22)
63 ; HOT99-NEXT: unreachable
65 ; HOT99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
66 ; HOT99-NEXT: ret i32 [[TMP5]]
68 ; HOT70-LABEL: define dso_local noundef i32 @simple(
69 ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) {
70 ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
71 ; HOT70-NEXT: [[HOT:%.*]] = xor i1 true, true
72 ; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
73 ; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
75 ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22)
76 ; HOT70-NEXT: unreachable
78 ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
79 ; HOT70-NEXT: ret i32 [[TMP5]]
81 ; NONE99-LABEL: define dso_local noundef i32 @simple(
82 ; NONE99-SAME: ptr noundef readonly [[TMP0:%.*]]) {
83 ; NONE99-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
84 ; NONE99-NEXT: [[HOT:%.*]] = xor i1 false, true
85 ; NONE99-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
86 ; NONE99-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
88 ; NONE99-NEXT: tail call void @llvm.ubsantrap(i8 22)
89 ; NONE99-NEXT: unreachable
91 ; NONE99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
92 ; NONE99-NEXT: ret i32 [[TMP5]]
94 ; ALL70-LABEL: define dso_local noundef i32 @simple(
95 ; ALL70-SAME: ptr noundef readonly [[TMP0:%.*]]) {
96 ; ALL70-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
97 ; ALL70-NEXT: [[HOT:%.*]] = xor i1 true, true
98 ; ALL70-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
99 ; ALL70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
101 ; ALL70-NEXT: tail call void @llvm.ubsantrap(i8 22)
102 ; ALL70-NEXT: unreachable
104 ; ALL70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
105 ; ALL70-NEXT: ret i32 [[TMP5]]
107 %chk = icmp eq ptr %0, null
108 %allow = call i1 @llvm.allow.ubsan.check(i8 22)
109 %hot = xor i1 %allow, true
110 %2 = or i1 %chk, %hot
111 br i1 %2, label %3, label %4
114 tail call void @llvm.ubsantrap(i8 22)
118 %5 = load i32, ptr %0, align 4
123 define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 {
124 ; NOPROFILE-LABEL: define dso_local noundef i32 @hot(
125 ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
126 ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
127 ; NOPROFILE-NEXT: [[HOT:%.*]] = xor i1 true, true
128 ; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
129 ; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
131 ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22)
132 ; NOPROFILE-NEXT: unreachable
134 ; NOPROFILE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
135 ; NOPROFILE-NEXT: ret i32 [[TMP5]]
137 ; NONE-LABEL: define dso_local noundef i32 @hot(
138 ; NONE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
139 ; NONE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
140 ; NONE-NEXT: [[HOT:%.*]] = xor i1 false, true
141 ; NONE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
142 ; NONE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
144 ; NONE-NEXT: tail call void @llvm.ubsantrap(i8 22)
145 ; NONE-NEXT: unreachable
147 ; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
148 ; NONE-NEXT: ret i32 [[TMP5]]
150 ; ALL-LABEL: define dso_local noundef i32 @hot(
151 ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
152 ; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
153 ; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
154 ; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
155 ; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
157 ; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
158 ; ALL-NEXT: unreachable
160 ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
161 ; ALL-NEXT: ret i32 [[TMP5]]
163 ; HOT99-LABEL: define dso_local noundef i32 @hot(
164 ; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
165 ; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
166 ; HOT99-NEXT: [[HOT:%.*]] = xor i1 false, true
167 ; HOT99-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
168 ; HOT99-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
170 ; HOT99-NEXT: tail call void @llvm.ubsantrap(i8 22)
171 ; HOT99-NEXT: unreachable
173 ; HOT99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
174 ; HOT99-NEXT: ret i32 [[TMP5]]
176 ; HOT70-LABEL: define dso_local noundef i32 @hot(
177 ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
178 ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
179 ; HOT70-NEXT: [[HOT:%.*]] = xor i1 true, true
180 ; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
181 ; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
183 ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22)
184 ; HOT70-NEXT: unreachable
186 ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
187 ; HOT70-NEXT: ret i32 [[TMP5]]
189 ; NONE99-LABEL: define dso_local noundef i32 @hot(
190 ; NONE99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
191 ; NONE99-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
192 ; NONE99-NEXT: [[HOT:%.*]] = xor i1 false, true
193 ; NONE99-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
194 ; NONE99-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
196 ; NONE99-NEXT: tail call void @llvm.ubsantrap(i8 22)
197 ; NONE99-NEXT: unreachable
199 ; NONE99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
200 ; NONE99-NEXT: ret i32 [[TMP5]]
202 ; ALL70-LABEL: define dso_local noundef i32 @hot(
203 ; ALL70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
204 ; ALL70-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
205 ; ALL70-NEXT: [[HOT:%.*]] = xor i1 true, true
206 ; ALL70-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
207 ; ALL70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
209 ; ALL70-NEXT: tail call void @llvm.ubsantrap(i8 22)
210 ; ALL70-NEXT: unreachable
212 ; ALL70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
213 ; ALL70-NEXT: ret i32 [[TMP5]]
215 %chk = icmp eq ptr %0, null
216 %allow = call i1 @llvm.allow.ubsan.check(i8 22)
217 %hot = xor i1 %allow, true
218 %2 = or i1 %chk, %hot
219 br i1 %2, label %3, label %4
222 tail call void @llvm.ubsantrap(i8 22)
226 %5 = load i32, ptr %0, align 4
230 define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 {
231 ; NOPROFILE-LABEL: define dso_local noundef i32 @veryHot(
232 ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
233 ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
234 ; NOPROFILE-NEXT: [[HOT:%.*]] = xor i1 true, true
235 ; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
236 ; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
238 ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22)
239 ; NOPROFILE-NEXT: unreachable
241 ; NOPROFILE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
242 ; NOPROFILE-NEXT: ret i32 [[TMP5]]
244 ; NONE-LABEL: define dso_local noundef i32 @veryHot(
245 ; NONE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
246 ; NONE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
247 ; NONE-NEXT: [[HOT:%.*]] = xor i1 false, true
248 ; NONE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
249 ; NONE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
251 ; NONE-NEXT: tail call void @llvm.ubsantrap(i8 22)
252 ; NONE-NEXT: unreachable
254 ; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
255 ; NONE-NEXT: ret i32 [[TMP5]]
257 ; ALL-LABEL: define dso_local noundef i32 @veryHot(
258 ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
259 ; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
260 ; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
261 ; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
262 ; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
264 ; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
265 ; ALL-NEXT: unreachable
267 ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
268 ; ALL-NEXT: ret i32 [[TMP5]]
270 ; HOT99-LABEL: define dso_local noundef i32 @veryHot(
271 ; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
272 ; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
273 ; HOT99-NEXT: [[HOT:%.*]] = xor i1 false, true
274 ; HOT99-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
275 ; HOT99-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
277 ; HOT99-NEXT: tail call void @llvm.ubsantrap(i8 22)
278 ; HOT99-NEXT: unreachable
280 ; HOT99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
281 ; HOT99-NEXT: ret i32 [[TMP5]]
283 ; HOT70-LABEL: define dso_local noundef i32 @veryHot(
284 ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
285 ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
286 ; HOT70-NEXT: [[HOT:%.*]] = xor i1 false, true
287 ; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], [[HOT]]
288 ; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]]
290 ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22)
291 ; HOT70-NEXT: unreachable
293 ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
294 ; HOT70-NEXT: ret i32 [[TMP5]]
296 ; NONE99-LABEL: define dso_local noundef i32 @veryHot(
297 ; NONE99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
298 ; NONE99-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
299 ; NONE99-NEXT: [[HOT:%.*]] = xor i1 false, true
300 ; NONE99-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
301 ; NONE99-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
303 ; NONE99-NEXT: tail call void @llvm.ubsantrap(i8 22)
304 ; NONE99-NEXT: unreachable
306 ; NONE99-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
307 ; NONE99-NEXT: ret i32 [[TMP5]]
309 ; ALL70-LABEL: define dso_local noundef i32 @veryHot(
310 ; ALL70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
311 ; ALL70-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
312 ; ALL70-NEXT: [[HOT:%.*]] = xor i1 false, true
313 ; ALL70-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
314 ; ALL70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
316 ; ALL70-NEXT: tail call void @llvm.ubsantrap(i8 22)
317 ; ALL70-NEXT: unreachable
319 ; ALL70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
320 ; ALL70-NEXT: ret i32 [[TMP5]]
322 %chk = icmp eq ptr %0, null
323 %allow = call i1 @llvm.allow.ubsan.check(i8 22)
324 %hot = xor i1 %allow, true
325 %2 = or i1 %chk, %hot
326 br i1 %2, label %3, label %4
329 tail call void @llvm.ubsantrap(i8 22)
333 %5 = load i32, ptr %0, align 4
338 define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readonly %1) !prof !39 {
339 ; NOPROFILE-LABEL: define dso_local noundef i32 @branchColdFnHot(
340 ; NOPROFILE-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
341 ; NOPROFILE-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
342 ; NOPROFILE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
344 ; NOPROFILE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
345 ; NOPROFILE-NEXT: [[HOT:%.*]] = xor i1 true, true
346 ; NOPROFILE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
347 ; NOPROFILE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
349 ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22)
350 ; NOPROFILE-NEXT: unreachable
352 ; NOPROFILE-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
353 ; NOPROFILE-NEXT: br label [[TMP9]]
355 ; NOPROFILE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
356 ; NOPROFILE-NEXT: ret i32 [[TMP10]]
358 ; NONE-LABEL: define dso_local noundef i32 @branchColdFnHot(
359 ; NONE-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
360 ; NONE-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
361 ; NONE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
363 ; NONE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
364 ; NONE-NEXT: [[HOT:%.*]] = xor i1 false, true
365 ; NONE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
366 ; NONE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
368 ; NONE-NEXT: tail call void @llvm.ubsantrap(i8 22)
369 ; NONE-NEXT: unreachable
371 ; NONE-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
372 ; NONE-NEXT: br label [[TMP9]]
374 ; NONE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
375 ; NONE-NEXT: ret i32 [[TMP10]]
377 ; ALL-LABEL: define dso_local noundef i32 @branchColdFnHot(
378 ; ALL-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
379 ; ALL-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
380 ; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
382 ; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
383 ; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
384 ; ALL-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
385 ; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
387 ; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
388 ; ALL-NEXT: unreachable
390 ; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
391 ; ALL-NEXT: br label [[TMP9]]
393 ; ALL-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
394 ; ALL-NEXT: ret i32 [[TMP10]]
396 ; HOT99-LABEL: define dso_local noundef i32 @branchColdFnHot(
397 ; HOT99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
398 ; HOT99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
399 ; HOT99-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
401 ; HOT99-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
402 ; HOT99-NEXT: [[HOT:%.*]] = xor i1 true, true
403 ; HOT99-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
404 ; HOT99-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
406 ; HOT99-NEXT: tail call void @llvm.ubsantrap(i8 22)
407 ; HOT99-NEXT: unreachable
409 ; HOT99-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
410 ; HOT99-NEXT: br label [[TMP9]]
412 ; HOT99-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
413 ; HOT99-NEXT: ret i32 [[TMP10]]
415 ; HOT70-LABEL: define dso_local noundef i32 @branchColdFnHot(
416 ; HOT70-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
417 ; HOT70-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
418 ; HOT70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
420 ; HOT70-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
421 ; HOT70-NEXT: [[HOT:%.*]] = xor i1 true, true
422 ; HOT70-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
423 ; HOT70-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
425 ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22)
426 ; HOT70-NEXT: unreachable
428 ; HOT70-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
429 ; HOT70-NEXT: br label [[TMP9]]
431 ; HOT70-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
432 ; HOT70-NEXT: ret i32 [[TMP10]]
434 ; NONE99-LABEL: define dso_local noundef i32 @branchColdFnHot(
435 ; NONE99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
436 ; NONE99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
437 ; NONE99-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
439 ; NONE99-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
440 ; NONE99-NEXT: [[HOT:%.*]] = xor i1 false, true
441 ; NONE99-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
442 ; NONE99-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
444 ; NONE99-NEXT: tail call void @llvm.ubsantrap(i8 22)
445 ; NONE99-NEXT: unreachable
447 ; NONE99-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
448 ; NONE99-NEXT: br label [[TMP9]]
450 ; NONE99-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
451 ; NONE99-NEXT: ret i32 [[TMP10]]
453 ; ALL70-LABEL: define dso_local noundef i32 @branchColdFnHot(
454 ; ALL70-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
455 ; ALL70-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
456 ; ALL70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
458 ; ALL70-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
459 ; ALL70-NEXT: [[HOT:%.*]] = xor i1 true, true
460 ; ALL70-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
461 ; ALL70-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
463 ; ALL70-NEXT: tail call void @llvm.ubsantrap(i8 22)
464 ; ALL70-NEXT: unreachable
466 ; ALL70-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
467 ; ALL70-NEXT: br label [[TMP9]]
469 ; ALL70-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
470 ; ALL70-NEXT: ret i32 [[TMP10]]
472 %3 = icmp eq i32 %0, 0
473 br i1 %3, label %9, label %4, !prof !38
476 %chk = icmp eq ptr %1, null
477 %allow = call i1 @llvm.allow.ubsan.check(i8 22)
478 %hot = xor i1 %allow, true
479 %5 = or i1 %chk, %hot
480 br i1 %5, label %6, label %7
483 tail call void @llvm.ubsantrap(i8 22) #2
487 %8 = load i32, ptr %1, align 4
491 %10 = phi i32 [ %8, %7 ], [ 0, %2 ]
495 define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readonly %1) !prof !36 {
496 ; NOPROFILE-LABEL: define dso_local noundef i32 @branchHotFnCold(
497 ; NOPROFILE-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
498 ; NOPROFILE-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
499 ; NOPROFILE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
501 ; NOPROFILE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
502 ; NOPROFILE-NEXT: [[HOT:%.*]] = xor i1 true, true
503 ; NOPROFILE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
504 ; NOPROFILE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
506 ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22)
507 ; NOPROFILE-NEXT: unreachable
509 ; NOPROFILE-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
510 ; NOPROFILE-NEXT: br label [[TMP9]]
512 ; NOPROFILE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
513 ; NOPROFILE-NEXT: ret i32 [[TMP10]]
515 ; NONE-LABEL: define dso_local noundef i32 @branchHotFnCold(
516 ; NONE-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
517 ; NONE-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
518 ; NONE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
520 ; NONE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
521 ; NONE-NEXT: [[HOT:%.*]] = xor i1 false, true
522 ; NONE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
523 ; NONE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
525 ; NONE-NEXT: tail call void @llvm.ubsantrap(i8 22)
526 ; NONE-NEXT: unreachable
528 ; NONE-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
529 ; NONE-NEXT: br label [[TMP9]]
531 ; NONE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
532 ; NONE-NEXT: ret i32 [[TMP10]]
534 ; ALL-LABEL: define dso_local noundef i32 @branchHotFnCold(
535 ; ALL-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
536 ; ALL-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
537 ; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
539 ; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
540 ; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
541 ; ALL-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
542 ; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
544 ; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
545 ; ALL-NEXT: unreachable
547 ; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
548 ; ALL-NEXT: br label [[TMP9]]
550 ; ALL-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
551 ; ALL-NEXT: ret i32 [[TMP10]]
553 ; HOT99-LABEL: define dso_local noundef i32 @branchHotFnCold(
554 ; HOT99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
555 ; HOT99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
556 ; HOT99-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
558 ; HOT99-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
559 ; HOT99-NEXT: [[HOT:%.*]] = xor i1 false, true
560 ; HOT99-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
561 ; HOT99-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
563 ; HOT99-NEXT: tail call void @llvm.ubsantrap(i8 22)
564 ; HOT99-NEXT: unreachable
566 ; HOT99-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
567 ; HOT99-NEXT: br label [[TMP9]]
569 ; HOT99-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
570 ; HOT99-NEXT: ret i32 [[TMP10]]
572 ; HOT70-LABEL: define dso_local noundef i32 @branchHotFnCold(
573 ; HOT70-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
574 ; HOT70-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
575 ; HOT70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
577 ; HOT70-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null
578 ; HOT70-NEXT: [[HOT:%.*]] = xor i1 true, true
579 ; HOT70-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], [[HOT]]
580 ; HOT70-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]]
582 ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22)
583 ; HOT70-NEXT: unreachable
585 ; HOT70-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
586 ; HOT70-NEXT: br label [[TMP9]]
588 ; HOT70-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
589 ; HOT70-NEXT: ret i32 [[TMP10]]
591 ; NONE99-LABEL: define dso_local noundef i32 @branchHotFnCold(
592 ; NONE99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
593 ; NONE99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
594 ; NONE99-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
596 ; NONE99-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
597 ; NONE99-NEXT: [[HOT:%.*]] = xor i1 false, true
598 ; NONE99-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
599 ; NONE99-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
601 ; NONE99-NEXT: tail call void @llvm.ubsantrap(i8 22)
602 ; NONE99-NEXT: unreachable
604 ; NONE99-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
605 ; NONE99-NEXT: br label [[TMP9]]
607 ; NONE99-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
608 ; NONE99-NEXT: ret i32 [[TMP10]]
610 ; ALL70-LABEL: define dso_local noundef i32 @branchHotFnCold(
611 ; ALL70-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
612 ; ALL70-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
613 ; ALL70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
615 ; ALL70-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
616 ; ALL70-NEXT: [[HOT:%.*]] = xor i1 true, true
617 ; ALL70-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
618 ; ALL70-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
620 ; ALL70-NEXT: tail call void @llvm.ubsantrap(i8 22)
621 ; ALL70-NEXT: unreachable
623 ; ALL70-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
624 ; ALL70-NEXT: br label [[TMP9]]
626 ; ALL70-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
627 ; ALL70-NEXT: ret i32 [[TMP10]]
629 %3 = icmp eq i32 %0, 0
630 br i1 %3, label %9, label %4, !prof !37
633 %chk = icmp eq ptr %1, null
634 %allow = call i1 @llvm.allow.ubsan.check(i8 22)
635 %hot = xor i1 %allow, true
636 %5 = or i1 %chk, %hot
637 br i1 %5, label %6, label %7
640 tail call void @llvm.ubsantrap(i8 22) #2
644 %8 = load i32, ptr %1, align 4
648 %10 = phi i32 [ %8, %7 ], [ 0, %2 ]
652 !llvm.module.flags = !{!6}
653 !6 = !{i32 1, !"ProfileSummary", !7}
654 !7 = !{!8, !9, !10, !11, !12, !13, !14, !17}
655 !8 = !{!"ProfileFormat", !"InstrProf"}
656 !9 = !{!"TotalCount", i64 30000}
657 !10 = !{!"MaxCount", i64 10000}
658 !11 = !{!"MaxInternalCount", i64 10000}
659 !12 = !{!"MaxFunctionCount", i64 10000}
660 !13 = !{!"NumCounts", i64 3}
661 !14 = !{!"NumFunctions", i64 5}
662 !17 = !{!"DetailedSummary", !18}
663 !18 = !{!19, !29, !30, !32, !34}
664 !19 = !{i32 10000, i64 10000, i32 3}
665 !29 = !{i32 950000, i64 5000, i32 3}
666 !30 = !{i32 990000, i64 500, i32 4}
667 !32 = !{i32 999900, i64 250, i32 4}
668 !34 = !{i32 999999, i64 1, i32 6}
670 !36 = !{!"function_entry_count", i64 1000}
671 !39 = !{!"function_entry_count", i64 7000}
673 !37 = !{!"branch_weights", i32 1, i32 1000}
674 !38 = !{!"branch_weights", i32 1000, i32 1}
677 ; NOPROFILE: [[PROF16]] = !{!"function_entry_count", i64 1000}
678 ; NOPROFILE: [[PROF17]] = !{!"function_entry_count", i64 7000}
679 ; NOPROFILE: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
680 ; NOPROFILE: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
682 ; NONE: [[PROF16]] = !{!"function_entry_count", i64 1000}
683 ; NONE: [[PROF17]] = !{!"function_entry_count", i64 7000}
684 ; NONE: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
685 ; NONE: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
687 ; ALL: [[PROF16]] = !{!"function_entry_count", i64 1000}
688 ; ALL: [[PROF17]] = !{!"function_entry_count", i64 7000}
689 ; ALL: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
690 ; ALL: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
692 ; HOT99: [[PROF16]] = !{!"function_entry_count", i64 1000}
693 ; HOT99: [[PROF17]] = !{!"function_entry_count", i64 7000}
694 ; HOT99: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
695 ; HOT99: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
697 ; HOT70: [[PROF16]] = !{!"function_entry_count", i64 1000}
698 ; HOT70: [[PROF17]] = !{!"function_entry_count", i64 7000}
699 ; HOT70: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
700 ; HOT70: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
702 ; NONE99: [[PROF16]] = !{!"function_entry_count", i64 1000}
703 ; NONE99: [[PROF17]] = !{!"function_entry_count", i64 7000}
704 ; NONE99: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
705 ; NONE99: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
707 ; ALL70: [[PROF16]] = !{!"function_entry_count", i64 1000}
708 ; ALL70: [[PROF17]] = !{!"function_entry_count", i64 7000}
709 ; ALL70: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
710 ; ALL70: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}