xref: /llvm-project/bolt/test/X86/tail-duplication-jt.s (revision 11791ae7b0b05b8bd8d806331ff51da618912cf8)
1## This reproduces a bug in tail duplication when aggressiveCodeToDuplicate
2## fails to handle a block with a jump table.
3
4# REQUIRES: system-linux
5
6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
7# RUN:   %s -o %t.o
8# RUN: link_fdata %s %t.o %t.fdata
9# RUN: llvm-strip --strip-unneeded %t.o
10# RUN: %clangxx %cflags -no-pie %t.o -o %t.exe -Wl,-q
11# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --relocs \
12# RUN:   --tail-duplication=aggressive \
13# RUN:   --print-cfg | FileCheck %s
14# CHECK: Jump table {{.*}} for function a at {{.*}} with a total count of 3
15  .globl main
16main:
17  .globl a
18  .type a, %function
19a:
20	.cfi_startproc
21b:
22  jmp	c
23  je	b
24  movl	%esi, %edi
25c:
26	movb	0, %cl
27d:
28  jmp	e
29	movq	0, %r14
30f:
31	je	d
32  jmp	f
33e:
34g:
35j:
36	movq	%rbp, 0
37h:
38	cmpl	$0x41, 0
39i:
40  jmp	h
41  jmp	i
42  ja	o
43	movl	%edx, 0
44p:
45q:
46k:
47  jmpq	*JT0(,%rcx,8)
48# FDATA: 1 a #k# 1 a #l# 1 3
49m:
50	movl	0, %esi
51r:
52  jmpq	*JT1(,%rax,8)
53	cmpl	1, %eax
54  jmp	j
55l:
56  jmp	m
57s:
58  movl	6, %ebx
59ak:
60  jmp	e
61	movl	0, %eax
62am:
63  jmp	p
64 	jmp	q
65o:
66  jmp	g
67n:
68	xorl	%r12d, %r12d
69	.cfi_endproc
70.rodata
71JT0:
72	.quad	r
73	.quad	l
74	.quad	ak
75JT1:
76	.quad	s
77	.quad	am
78	.quad	n
79