[LV] Add test showing debug output for loops with uncountable BTCs.
[llvm-project.git] / bolt / test / AArch64 / exclusive-instrument.s
blob69cc0707aba8e4aea58b7168aae409422a4d94f1
1 // This test checks that the foo function having exclusive memory access
2 // instructions won't be instrumented.
4 // REQUIRES: system-linux,bolt-runtime,target=aarch64{{.*}}
6 // RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
7 // RUN: %s -o %t.o
8 // RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q -Wl,-fini=dummy
9 // RUN: llvm-bolt %t.exe -o %t.bolt -instrument -v=2 | FileCheck %s
11 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
12 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
13 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo
14 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case1
15 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case2
16 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case2
17 // CHECK: BOLT-INSTRUMENTER: function case3 has exclusive store without corresponding load. Ignoring the function.
18 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case4
19 // CHECK: BOLT-INSTRUMENTER: function case4 has two exclusive loads. Ignoring the function.
20 // CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case5
21 // CHECK: BOLT-INSTRUMENTER: function case5 has exclusive load in trailing BB. Ignoring the function.
23 .global foo
24 .type foo, %function
25 foo:
26 # exclusive load and store in two bbs
27 ldaxr w9, [x10]
28 cbnz w9, .Lret
29 stlxr w12, w11, [x9]
30 cbz w12, foo
31 .Lret:
32 clrex
33 ret
34 .size foo, .-foo
36 .global _start
37 .type _start, %function
38 _start:
39 mov x0, #0
40 mov x1, #1
41 mov x2, #2
42 mov x3, #3
44 bl case1
45 bl case2
46 bl case3
47 bl case4
48 bl case5
50 ret
51 .size _start, .-_start
53 # Case 1: exclusive load and store in one basic block
54 .global case1
55 .type case1, %function
56 case1:
57 str x0, [x2]
58 ldxr w0, [x2]
59 add w0, w0, #1
60 stxr w1, w0, [x2]
61 ret
62 .size case1, .-case1
64 # Case 2: exclusive load and store in different blocks
65 .global case2
66 .type case2, %function
67 case2:
68 b case2_load
70 case2_load:
71 ldxr x0, [x2]
72 b case2_store
74 case2_store:
75 add x0, x0, #1
76 stxr w1, x0, [x2]
77 ret
78 .size case2, .-case2
80 # Case 3: store without preceding load
81 .global case3
82 .type case3, %function
83 case3:
84 stxr w1, x3, [x2]
85 ret
86 .size case3, .-case3
88 # Case 4: two exclusive load instructions in neighboring blocks
89 .global case4
90 .type case4, %function
91 case4:
92 b case4_load
94 case4_load:
95 ldxr x0, [x2]
96 b case4_load_next
98 case4_load_next:
99 ldxr x1, [x2]
101 .size case4, .-case4
103 # Case 5: Exclusive load without successor
104 .global case5
105 .type case5, %function
106 case5:
107 ldxr x0, [x2]
109 .size case5, .-case5
111 .global dummy
112 .type dummy, %function
113 dummy:
115 .size dummy, .-dummy