[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / bolt / test / AArch64 / test-indirect-branch.s
blob168e50c8f47f52d393ea67fc3b9cbae6f718836f
1 // Test how BOLT handles indirect branch sequence of instructions in
2 // AArch64MCPlus builder.
4 // clang-format off
6 // REQUIRES: system-linux
7 // RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
8 // RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q
9 // RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --strict\
10 // RUN: -v=1 2>&1 | FileCheck %s
12 // Pattern 1: there is no shift amount after the 'add' instruction.
14 // adr x6, 0x219fb0 <sigall_set+0x88>
15 // add x6, x6, x14, lsl #2
16 // ldr w7, [x6]
17 // add x6, x6, w7, sxtw => no shift amount
18 // br x6
21 // Pattern 2: nop/adr pair is used in place of adrp/add
23 // nop => nop/adr instead of adrp/add
24 // adr x13, 0x215a18 <_nl_value_type_LC_COLLATE+0x50>
25 // ldrh w13, [x13, w12, uxtw #1]
26 // adr x12, 0x247b30 <__gettextparse+0x5b0>
27 // add x13, x12, w13, sxth #2
28 // br x13
30 .section .text
31 .align 4
32 .globl _start
33 .type _start, %function
34 _start:
35 bl test1
36 bl test2
37 // mov x0, #4
38 // mov w8, #93
39 // svc #0
41 // Pattern 1
42 // CHECK: BOLT-WARNING: Failed to match indirect branch: ShiftVAL != 2
43 .globl test1
44 .type test1, %function
45 test1:
46 mov x1, #0
47 adr x3, datatable
48 add x3, x3, x1, lsl #2
49 ldr w2, [x3]
50 add x3, x3, w2, sxtw
51 br x3
52 test1_0:
53 ret
54 test1_1:
55 ret
56 test1_2:
57 ret
59 // Pattern 2
60 // CHECK: BOLT-WARNING: Failed to match indirect branch: nop/adr instead of adrp/add
61 .globl test2
62 .type test2, %function
63 test2:
64 nop
65 adr x3, jump_table
66 ldrh w3, [x3, x1, lsl #1]
67 adr x1, test2_0
68 add x3, x1, w3, sxth #2
69 br x3
70 test2_0:
71 ret
72 test2_1:
73 ret
75 .section .rodata,"a",@progbits
76 datatable:
77 .word test1_0-datatable
78 .word test1_1-datatable
79 .word test1_2-datatable
81 jump_table:
82 .hword (test2_0-test2_0)>>2
83 .hword (test2_1-test2_0)>>2