[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / bolt / test / X86 / split-func-jump-table-unknown.s
blob71a172bb5f4a43975c74c43de58f3cea1bedf57e
1 # This reproduces a bug with converting an unknown control flow jump table with
2 # entries pointing to code in function and its cold fragment.
4 # REQUIRES: system-linux
6 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
7 # RUN: llvm-strip --strip-unneeded %t.o
8 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
9 # RUN: llvm-bolt %t.exe -o %t.out --lite=0 -v=1 --strict=1 -print-cfg \
10 # RUN: -print-only=main 2>&1 | FileCheck %s
12 # CHECK: BOLT-INFO: marking main.cold.1 as a fragment of main
13 # CHECK: Binary Function "main" after building cfg
14 # CHECK: Unknown CF : true
15 # CHECK: jmpq *%r8 # UNKNOWN CONTROL FLOW
16 # CHECK: PIC Jump table JUMP_TABLE for function main
17 # CHECK-NEXT: 0x0000 : .Ltmp0
18 # CHECK-NEXT: 0x0004 : .Ltmp1
19 # CHECK-NEXT: 0x0008 : __ENTRY_main.cold.1
20 # CHECK-NEXT: 0x000c : .Ltmp1
21 .text
22 .globl main
23 .type main, %function
24 .p2align 2
25 main:
26 LBB0:
27 leaq JUMP_TABLE(%rip), %r8
28 andl $0xf, %ecx
29 cmpb $0x4, %cl
30 # exit through abort in main.cold.1, registers cold fragment the regular way
31 ja main.cold.1
33 # jump table dispatch, jumping to label indexed by val in %ecx
34 LBB1:
35 movzbl %cl, %ecx
36 movslq (%r8,%rcx,4), %rax
37 addq %rax, %r8
38 jmpq *%r8
40 LBB2:
41 xorq %rax, %rax
42 LBB3:
43 addq $0x8, %rsp
44 ret
45 .size main, .-main
47 .globl main.cold.1
48 .type main.cold.1, %function
49 .p2align 2
50 main.cold.1:
51 # load bearing nop: pad LBB4 so that it can't be treated
52 # as __builtin_unreachable by analyzeJumpTable
53 nop
54 LBB4:
55 callq abort
56 .size main.cold.1, .-main.cold.1
58 .rodata
59 # jmp table, entries must be R_X86_64_PC32 relocs
60 .globl JUMP_TABLE
61 JUMP_TABLE:
62 .long LBB2-JUMP_TABLE
63 .long LBB3-JUMP_TABLE
64 .long LBB4-JUMP_TABLE
65 .long LBB3-JUMP_TABLE