[NFC][RemoveDIs] Prefer iterators over inst-pointers in InstCombine
[llvm-project.git] / llvm / test / CodeGen / AArch64 / branch-relax-xray.ll
blobb066314ef8a37956e15371724acfc28d71f7e006
1 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu -aarch64-tbz-offset-bits=4 -aarch64-cbz-offset-bits=3 < %s | FileCheck %s
3 ;; Check that branch relaxation accounts for the size of xray EXIT sleds
4 ;; Note that TAIL_CALL sleds don't exist on AArch64 and don't need a test.
5 define void @exit(i1 zeroext %0) nounwind "function-instrument"="xray-always" {
6 ; CHECK-LABEL: exit:
7 ; CHECK-NEXT:     .Lfunc_begin0:
8 ; CHECK-NEXT:     // %bb.0:
9 ; CHECK-NEXT:       .p2align 2
10 ; CHECK-NEXT:     .Lxray_sled_0:
11 ; CHECK-NEXT:       b #32
12 ; CHECK-COUNT-7:    nop
13 ; CHECK-NOT:        nop
14 ; CHECK:            tbnz
15 ; CHECK-SAME:            [[FALLTHROUGH:.LBB[0-9_]+]]
16 ; CHECK-NEXT:       b
17 ; CHECK-SAME:         [[OUT_OF_RANGE:.LBB[0-9_]+]]
18 ; CHECK-NEXT:     [[FALLTHROUGH]]:
19 ; CHECK-NEXT:       bl      bar
20 ; CHECK:            .p2align 2
21 ; CHECK-NEXT:     .Lxray_sled_1:
22 ; CHECK-NEXT:       b #32
23 ; CHECK-COUNT-7:    nop
24 ; CHECK-NOT:        nop
25 ; CHECK-NEXT:     .Ltmp1:
26 ; CHECK-NEXT:       ret
27 ; CHECK-NEXT:     [[OUT_OF_RANGE]]:
28 ; CHECK-SAME:                        // %end2
29 ; CHECK-NEXT:       bl      baz
30   br i1 %0, label %end1, label %end2
32 end1:
33   %2 = call i32 @bar()
34   ret void
36 end2:
37   %3 = call i32 @baz()
38   ret void
41 ;; Check that branch relaxation accounts for the size of xray EVENT sleds
42 define void @customevent(i1 zeroext %0, ptr nocapture noundef readonly %e1, i64 noundef %s1, ptr nocapture noundef readonly %e2, i64 noundef %s2) "function-instrument"="xray-always" {
43 ; CHECK-LABEL: customevent:
44 ; CHECK-NEXT:     .Lfunc_begin1:
45 ; CHECK-NEXT:       .cfi_startproc
46 ; CHECK-NEXT:       // %bb.0:
47 ; CHECK-NEXT:       .p2align 2
48 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
49 ; CHECK:            cbnz
50 ; CHECK-SAME:           [[FALLTHROUGH_2:.LBB[0-9_]+]]
51 ; CHECK-NEXT:       b
52 ; CHECK-SAME:           [[OUT_OF_RANGE_2:.LBB[0-9_]+]]
53 ; CHECK-NEXT:     [[FALLTHROUGH_2]]:
54 ; CHECK-SAME:                        // %end1
55 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
56 ; CHECK-NEXT:         Begin XRay custom event
57 ; CHECK:            bl      __xray_CustomEvent
58 ; CHECK:              End XRay custom event
59 ; CHECK-NEXT:     [[OUT_OF_RANGE_2]]:
60 ; CHECK-SAME:                        // %end2
61 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
62 ; CHECK-NEXT:         Begin XRay custom event
63 ; CHECK:            bl      __xray_CustomEvent
64 ; CHECK:              End XRay custom event
65 ; CHECK:          .Ltmp
66 ; CHECK-NEXT:       ret
67 entry:
68   br i1 %0, label %end1, label %end2
70 end1:
71   call void @llvm.xray.customevent(ptr %e1, i64 %s1)
72   br label %end2
74 end2:
75   tail call void @llvm.xray.customevent(ptr %e2, i64 %s2)
76   ret void
79 ;; Check that branch relaxation accounts for the size of xray TYPED_EVENT sleds
80 define void @typedevent(i1 zeroext %0, i64 noundef %type, ptr nocapture noundef readonly %event, i64 noundef %size) "function-instrument"="xray-always" {
81 ; CHECK-LABEL: typedevent:
82 ; CHECK-NEXT:     .Lfunc_begin2:
83 ; CHECK-NEXT:       .cfi_startproc
84 ; CHECK-NEXT:       // %bb.0:
85 ; CHECK-NEXT:       .p2align 2
86 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
87 ; CHECK:            cbnz
88 ; CHECK-SAME:           [[FALLTHROUGH_3:.LBB[0-9_]+]]
89 ; CHECK-NEXT:       b
90 ; CHECK-SAME:           [[OUT_OF_RANGE_3:.LBB[0-9_]+]]
91 ; CHECK-NEXT:     [[FALLTHROUGH_3]]:
92 ; CHECK-SAME:                        // %end1
93 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
94 ; CHECK-NEXT:         Begin XRay typed event
95 ; CHECK:            bl      __xray_TypedEvent
96 ; CHECK:              End XRay typed event
97 ; CHECK-NEXT:     [[OUT_OF_RANGE_3]]:
98 ; CHECK-SAME:                        // %end2
99 ; CHECK-NEXT:     .Lxray_sled_{{[0-9]+}}:
100 ; CHECK-NEXT:         Begin XRay typed event
101 ; CHECK:            bl      __xray_TypedEvent
102 ; CHECK:              End XRay typed event
103 ; CHECK:          .Ltmp
104 ; CHECK-NEXT:       ret
105 entry:
106   br i1 %0, label %end1, label %end2
108 end1:
109   call void @llvm.xray.typedevent(i64 %type, ptr %event, i64 %size)
110   br label %end2
111   
112 end2:
113   tail call void @llvm.xray.typedevent(i64 %size, ptr %event, i64 %type)
114   ret void
117 declare void @llvm.xray.customevent(ptr, i64)
118 declare void @llvm.xray.typedevent(i64, ptr, i64)
119 declare i32 @bar()
120 declare i32 @baz()