xref: /llvm-project-15.0.7/bolt/test/X86/issue20.s (revision d648aa1b)
1# This reproduces issue 20 from our github repo
2#  "BOLT crashes when removing unreachable BBs that are a target
3#   in a JT"
4
5# REQUIRES: system-linux
6
7# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
8# RUN:   %s -o %t.o
9# RUN: %clang %cflags -no-pie %t.o -o %t.exe
10# RUN: llvm-bolt %t.exe --relocs=0 --jump-tables=move --print-finalized \
11# RUN:    -o %t.out | FileCheck %s
12
13# CHECK: BOLT-INFO: UCE removed 0 blocks and 0 bytes of code.
14# CHECK: Binary Function "main"
15# CHECK:      .LFT{{.*}} (2 instructions, align : 1)
16# CHECK-NEXT:   CFI State : 0
17# CHECK-NEXT:     00000004:   andq
18# CHECK-NEXT:     00000008:   jmpq
19# CHECK-NEXT:   Successors: .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}
20
21
22  .text
23  .globl main
24  .type main, %function
25  .size main, .Lend1-main
26main:
27  xorq %rax, %rax
28  retq
29  andq $3, %rdi
30  jmpq *jumptbl(,%rdi,8)
31
32.Lbb1:
33  movl $0x1, %eax
34  jmp .Lexit
35.Lbb2:
36  movl $0x2, %eax
37  jmp .Lexit
38.Lbb3:
39  movl $0x3, %eax
40  jmp .Lexit
41.Lbb4:
42  movl $0x4, %eax
43.Lexit:
44  retq
45.Lend1:
46
47  .section .rodata
48  .globl jumptbl
49jumptbl:
50  .quad .Lbb1
51  .quad .Lbb2
52  .quad .Lbb3
53  .quad .Lbb4
54