xref: /llvm-project/bolt/test/X86/issue20.s (revision ca06b610841c849eb1db43ad057310c8f7eea81e)
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-NOT: BOLT-INFO: UCE removed {{.*}} blocks and {{.*}} bytes of code
14# CHECK: Binary Function "main"
15# CHECK:      .LFT{{.*}} (2 instructions, align : 1)
16# CHECK-NEXT:     00000004:   andq
17# CHECK-NEXT:     00000008:   jmpq
18# CHECK-NEXT:   Successors: .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}
19
20
21  .text
22  .globl main
23  .type main, %function
24  .size main, .Lend1-main
25main:
26  xorq %rax, %rax
27  retq
28  andq $3, %rdi
29  jmpq *jumptbl(,%rdi,8)
30
31.Lbb1:
32  movl $0x1, %eax
33  jmp .Lexit
34.Lbb2:
35  movl $0x2, %eax
36  jmp .Lexit
37.Lbb3:
38  movl $0x3, %eax
39  jmp .Lexit
40.Lbb4:
41  movl $0x4, %eax
42.Lexit:
43  retq
44.Lend1:
45
46  .section .rodata
47  .globl jumptbl
48jumptbl:
49  .quad .Lbb1
50  .quad .Lbb2
51  .quad .Lbb3
52  .quad .Lbb4
53