Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / X86 / split-func-jump-table-fragment.s
bloba92e6731dffe6b1e994d4073711560a933c62a4e
1 ## This reproduces a bug with jump table identification where jump table has
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 --print-cfg --print-only=main \
10 # RUN: 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 abort in main.cold.1, registers cold fragment the regular way
23 ja main.cold.1
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 # Insert padding between functions, so that the next instruction cannot be
41 # treated as __builtin_unreachable destination for the jump table.
42 .quad 0
44 .globl main.cold.1
45 .type main.cold.1, %function
46 .p2align 2
47 main.cold.1:
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
61 ## Verify that the entry corresponding to the cold fragment was added to
62 ## the jump table.
64 # CHECK: PIC Jump table
65 # CHECK-NEXT: 0x{{.*}} :
66 # CHECK-NEXT: 0x{{.*}} :
67 # CHECK-NEXT: 0x{{.*}} : main.cold.1
68 # CHECK-NEXT: 0x{{.*}} :