[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / bolt / test / X86 / split-func-jump-table-fragment-noparent.s
bloba3ac643ee1376a2400115fce67502950991c2864
1 # This reproduces a bug with jump table identification where jump table has
2 # entries pointing to code in function and its cold fragment.
3 # The fragment is only reachable through jump table.
5 # REQUIRES: system-linux
7 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
8 # RUN: llvm-strip --strip-unneeded %t.o
9 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
10 # RUN: llvm-bolt %t.exe -o %t.out --lite=0 -v=1 2>&1 | FileCheck %s
12 # CHECK-NOT: unclaimed PC-relative relocations left in data
13 # CHECK: BOLT-INFO: marking main.cold.1 as a fragment of main
14 .text
15 .globl main
16 .type main, %function
17 .p2align 2
18 main:
19 LBB0:
20 andl $0xf, %ecx
21 cmpb $0x4, %cl
22 # exit through ret
23 ja LBB3
25 # jump table dispatch, jumping to label indexed by val in %ecx
26 LBB1:
27 leaq JUMP_TABLE(%rip), %r8
28 movzbl %cl, %ecx
29 movslq (%r8,%rcx,4), %rax
30 addq %rax, %r8
31 jmpq *%r8
33 LBB2:
34 xorq %rax, %rax
35 LBB3:
36 addq $0x8, %rsp
37 ret
38 .size main, .-main
40 # cold fragment is only reachable through jump table
41 .globl main.cold.1
42 .type main.cold.1, %function
43 .p2align 2
44 main.cold.1:
45 # load bearing nop: pad LBB4 so that it can't be treated
46 # as __builtin_unreachable by analyzeJumpTable
47 nop
48 LBB4:
49 callq abort
50 .size main.cold.1, .-main.cold.1
52 .rodata
53 # jmp table, entries must be R_X86_64_PC32 relocs
54 .globl JUMP_TABLE
55 JUMP_TABLE:
56 .long LBB2-JUMP_TABLE
57 .long LBB3-JUMP_TABLE
58 .long LBB4-JUMP_TABLE
59 .long LBB3-JUMP_TABLE