116 lines · plain
1// This test checks that the foo function having exclusive memory access2// instructions won't be instrumented.3 4// REQUIRES: system-linux,bolt-runtime,target=aarch64{{.*}}5 6// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \7// RUN: %s -o %t.o8// RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q -Wl,-fini=dummy9// RUN: llvm-bolt %t.exe -o %t.bolt -instrument -v=2 | FileCheck %s10 11// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo12// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo13// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function foo14// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case115// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case216// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case217// 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 case419// CHECK: BOLT-INSTRUMENTER: function case4 has two exclusive loads. Ignoring the function.20// CHECK: BOLT-INSTRUMENTER: skip BB {{.*}} due to exclusive instruction in function case521// CHECK: BOLT-INSTRUMENTER: function case5 has exclusive load in trailing BB. Ignoring the function.22 23.global foo24.type foo, %function25foo:26 # exclusive load and store in two bbs27 ldaxr w9, [x10]28 cbnz w9, .Lret29 stlxr w12, w11, [x9]30 cbz w12, foo31.Lret:32 clrex33 ret34.size foo, .-foo35 36.global _start37.type _start, %function38_start:39 mov x0, #040 mov x1, #141 mov x2, #242 mov x3, #343 44 bl case145 bl case246 bl case347 bl case448 bl case549 50 ret51.size _start, .-_start52 53# Case 1: exclusive load and store in one basic block54.global case155.type case1, %function56case1:57 str x0, [x2]58 ldxr w0, [x2]59 add w0, w0, #160 stxr w1, w0, [x2]61 ret62.size case1, .-case163 64# Case 2: exclusive load and store in different blocks65.global case266.type case2, %function67case2:68 b case2_load69 70case2_load:71 ldxr x0, [x2]72 b case2_store73 74case2_store:75 add x0, x0, #176 stxr w1, x0, [x2]77 ret78.size case2, .-case279 80# Case 3: store without preceding load81.global case382.type case3, %function83case3:84 stxr w1, x3, [x2]85 ret86.size case3, .-case387 88# Case 4: two exclusive load instructions in neighboring blocks89.global case490.type case4, %function91case4:92 b case4_load93 94case4_load:95 ldxr x0, [x2]96 b case4_load_next97 98case4_load_next:99 ldxr x1, [x2]100 ret101.size case4, .-case4102 103# Case 5: Exclusive load without successor104.global case5105.type case5, %function106case5:107 ldxr x0, [x2]108 ret109.size case5, .-case5110 111.global dummy112.type dummy, %function113dummy:114 ret115.size dummy, .-dummy116