Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / X86 / split-func-jump-table-fragment-reverse.s
blob639c800a795b1ea73f1342396e6040032d328f54
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 as a fragment of main
14 .text
15 .globl _start
16 .type _start, %function
17 _start:
18 callq main.cold
19 call exit
20 .size _start, .-_start
22 .globl main.cold
23 .type main.cold, %function
24 .p2align 2
25 main.cold:
26 LBB0:
27 andl $0xf, %ecx
28 cmpb $0x4, %cl
29 # exit through ret
30 ja LBB3
32 # jump table dispatch, jumping to label indexed by val in %ecx
33 LBB1:
34 leaq JUMP_TABLE(%rip), %r8
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.cold, .-main.cold
47 # main function, referenced from jump table in cold fragment
48 .globl main
49 .type main, %function
50 .p2align 2
51 main:
52 # load bearing nop: pad LBB4 so that it can't be treated
53 # as __builtin_unreachable by analyzeJumpTable
54 nop
55 LBB4:
56 callq abort
57 .size main, .-main
59 .rodata
60 # jmp table, entries must be R_X86_64_PC32 relocs
61 .globl JUMP_TABLE
62 JUMP_TABLE:
63 .long LBB2-JUMP_TABLE
64 .long LBB3-JUMP_TABLE
65 .long LBB4-JUMP_TABLE
66 .long LBB3-JUMP_TABLE