Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / X86 / split-func-jump-table-fragment-bidirection.s
blobcaebe59ed086569893d8dc4f8b018002e8bc724f
1 # This reproduces an issue where two fragments of same function access same
2 # jump table, which means at least one fragment visits the other, i.e., one
3 # of them has split jump table. As a result, all of them will be marked as
4 # non-simple function.
6 # REQUIRES: system-linux
8 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
9 # RUN: llvm-strip --strip-unneeded %t.o
10 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
11 # RUN: llvm-bolt -print-cfg -v=3 %t.exe -o %t.out 2>&1 | FileCheck %s
13 # CHECK: BOLT-INFO: Multiple fragments access same jump table: main; main.cold.1
14 # CHECK: PIC Jump table JUMP_TABLE1 for function main, main.cold.1 at {{.*}} with a total count of 0:
16 .text
17 .globl main
18 .type main, %function
19 .p2align 2
20 main:
21 LBB0:
22 andl $0xf, %ecx
23 cmpb $0x4, %cl
24 # exit through ret
25 ja LBB3
27 # jump table dispatch, jumping to label indexed by val in %ecx
28 LBB1:
29 leaq JUMP_TABLE1(%rip), %r8
30 movzbl %cl, %ecx
31 movslq (%r8,%rcx,4), %rax
32 addq %rax, %r8
33 jmpq *%r8
35 LBB2:
36 xorq %rax, %rax
37 LBB3:
38 addq $0x8, %rsp
39 ret
40 .size main, .-main
42 # cold fragment is only reachable
43 .globl main.cold.1
44 .type main.cold.1, %function
45 .p2align 2
46 main.cold.1:
47 # load bearing nop: pad LBB8 so that it can't be treated
48 # as __builtin_unreachable by analyzeJumpTable
49 nop
50 LBB4:
51 andl $0xb, %ebx
52 cmpb $0x1, %cl
53 # exit through ret
54 ja LBB7
56 # jump table dispatch, jumping to label indexed by val in %ecx
57 LBB5:
58 leaq JUMP_TABLE1(%rip), %r8
59 movzbl %cl, %ecx
60 movslq (%r8,%rcx,4), %rax
61 addq %rax, %r8
62 jmpq *%r8
64 LBB6:
65 xorq %rax, %rax
66 LBB7:
67 addq $0x8, %rsp
68 ret
69 LBB8:
70 callq abort
71 .size main.cold.1, .-main.cold.1
73 .rodata
74 # jmp table, entries must be R_X86_64_PC32 relocs
75 .globl JUMP_TABLE1
76 JUMP_TABLE1:
77 .long LBB2-JUMP_TABLE1
78 .long LBB3-JUMP_TABLE1
79 .long LBB8-JUMP_TABLE1
80 .long LBB6-JUMP_TABLE1
81 .long LBB7-JUMP_TABLE1