1 ; RUN: llc -O3 -mtriple arm64-linux -filetype asm -o - %s | FileCheck %s -check-prefix CHECK-ASM
2 ; What this test does is check that even with nomerge, the functions still get merged in
3 ; compiled code as the ubsantrap call gets lowered to a single instruction: brk.
6 @B = dso_local global [10 x i8] zeroinitializer, align 1
7 @B2 = dso_local global [10 x i8] zeroinitializer, align 1
9 ; Function Attrs: noinline nounwind uwtable
10 define dso_local void @f8(i32 noundef %i, i32 noundef %k) #0 {
12 ; CHECK-ASM: cmp x8, #10
13 ; CHECK-ASM: b.hi .LBB0_5
14 ; CHECK-ASM: // %bb.1: // %entry
15 ; CHECK-ASM: mov w9, #10 // =0xa
16 ; CHECK-ASM: sub x9, x9, x8
17 ; CHECK-ASM: cbz x9, .LBB0_5
18 ; CHECK-ASM: // %bb.2:
19 ; CHECK-ASM: ldrsw x9, [sp, #8]
20 ; CHECK-ASM: adrp x10, B
21 ; CHECK-ASM: add x10, x10, :lo12:B
22 ; CHECK-ASM: strb wzr, [x10, x8]
23 ; CHECK-ASM: cmp x9, #10
24 ; CHECK-ASM: b.hi .LBB0_5
25 ; CHECK-ASM: // %bb.3:
26 ; CHECK-ASM: mov w8, #10 // =0xa
27 ; CHECK-ASM: sub x8, x8, x9
28 ; CHECK-ASM: cbz x8, .LBB0_5
29 ; CHECK-ASM: // %bb.4:
30 ; CHECK-ASM: adrp x8, B2
31 ; CHECK-ASM: add x8, x8, :lo12:B2
32 ; CHECK-ASM: strb wzr, [x8, x9]
33 ; CHECK-ASM: add sp, sp, #16
34 ; CHECK-ASM: .cfi_def_cfa_offset 0
36 ; CHECK-ASM: .LBB0_5: // %trap3
37 ; CHECK-ASM: .cfi_restore_state
39 %i.addr = alloca i32, align 4
40 %k.addr = alloca i32, align 4
41 store i32 %i, ptr %i.addr, align 4
42 store i32 %k, ptr %k.addr, align 4
43 %0 = load i32, ptr %i.addr, align 4
44 %idxprom = sext i32 %0 to i64
45 %1 = add i64 0, %idxprom
46 %arrayidx = getelementptr inbounds [10 x i8], ptr @B, i64 0, i64 %idxprom
48 %3 = icmp ult i64 10, %1
49 %4 = icmp ult i64 %2, 1
51 br i1 %5, label %trap, label %6
54 store i8 0, ptr %arrayidx, align 1
55 %7 = load i32, ptr %k.addr, align 4
56 %idxprom1 = sext i32 %7 to i64
57 %8 = add i64 0, %idxprom1
58 %arrayidx2 = getelementptr inbounds [10 x i8], ptr @B2, i64 0, i64 %idxprom1
60 %10 = icmp ult i64 10, %8
61 %11 = icmp ult i64 %9, 1
63 br i1 %12, label %trap3, label %13
66 store i8 0, ptr %arrayidx2, align 1
69 trap: ; preds = %entry
70 call void @llvm.trap() #2
74 call void @llvm.trap() #2
78 ; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
79 declare void @llvm.trap() #1
81 attributes #0 = { noinline nounwind uwtable }
82 attributes #1 = { cold noreturn nounwind memory(inaccessiblemem: write) }
83 attributes #2 = { noreturn nounwind nomerge }