[NFC][MLIR][Linalg] Refactor linalg.matmul tablegen ODS and related C++ code. (#116377)
[llvm-project.git] / bolt / test / runtime / X86 / jt-symbol-disambiguation.s
blobea3b8934dd434a9715ee9347799c1cb54f070a71
1 # In this test case, the symbol that represents the end of a table
2 # in .rodata is being colocated with the start of a jump table from
3 # another function, and BOLT moves that jump table. This should not
4 # cause the symbol representing the end of the table to be moved as
5 # well.
6 # Bug reported in https://github.com/llvm/llvm-project/issues/55004
8 # REQUIRES: system-linux
10 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
11 # RUN: llvm-strip --strip-unneeded %t.o
12 # RUN: %clang %cflags -no-pie -nostartfiles -nostdlib -lc %t.o -o %t.exe -Wl,-q
14 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \
15 # RUN: --reorder-blocks=reverse -jump-tables=move
17 # RUN: %t.exe.bolt 1 2 3
19 .file "jt-symbol-disambiguation.s"
20 .text
22 # ----
23 # Func foo contains a jump table whose start is colocated with a
24 # symbol marking the end of a data table
25 # ----
26 .globl foo
27 .type foo, @function
28 foo:
29 .cfi_startproc
30 xor %rax,%rax
31 and $0x3,%rdi
32 leaq .JT1(%rip), %rax
33 movslq (%rax, %rdi, 4), %rdi
34 addq %rax, %rdi
35 jmpq *%rdi
36 .LBB1:
37 movl $0x1,%eax
38 jmp .LBB5
39 .LBB2:
40 movl $0x2,%eax
41 jmp .LBB5
42 .LBB3:
43 movl $0x3,%eax
44 jmp .LBB5
45 .LBB4:
46 movl $0x4,%eax
47 .LBB5:
48 retq
49 .cfi_endproc
50 .size foo, .-foo
52 # ----
53 # Func _start scans a table using begin/end pointers. End pointer is colocated
54 # with the start of a jump table of function foo. When that jump
55 # table moves, end pointer in _start should not be affected.
56 # ----
57 .globl _start
58 .type _start, @function
59 _start:
60 .cfi_startproc
61 movq (%rsp), %rdi
62 callq foo
63 leaq .start_of_table(%rip), %rsi # iterator
64 leaq .end_of_table(%rip), %rdi # iterator end
65 .LBB6:
66 cmpq %rsi, %rdi
67 je .LBB7
68 movq (%rsi), %rbx
69 leaq 8(%rsi), %rsi # ++iterator
70 jmp .LBB6
71 .LBB7:
72 xor %rdi, %rdi
73 callq exit@PLT
74 .cfi_endproc
75 .size _start, .-_start
77 # ----
78 # Data section
79 # ----
80 .section .rodata,"a",@progbits
81 .p2align 3
82 .start_of_table:
83 .quad 123
84 .quad 456
85 .quad 789
86 .end_of_table:
87 .JT1:
88 .long .LBB1 - .JT1
89 .long .LBB2 - .JT1
90 .long .LBB3 - .JT1
91 .long .LBB4 - .JT1