xref: /llvm-project/bolt/test/X86/pie-eh-split-undo.s (revision 105ecd8bb2c90c874375100e61f85678a0f6e310)
1# REQUIRES: system-linux
2
3# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
4# RUN: link_fdata %s %t.o %t.fdata
5# RUN: llvm-strip --strip-unneeded %t.o
6# RUN: ld.lld --pie %t.o -o %t.exe -q
7# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --split-functions --split-eh \
8# RUN:   --split-all-cold --print-after-lowering  --print-only=_start 2>&1 \
9# RUN:   | FileCheck %s
10
11## _start has two landing pads: one hot and one cold. Hence, BOLT will introduce
12## a landing pad trampoline. However, the trampoline code will make the main
13## split fragment larger than the whole function before split. Then BOLT will
14## undo the splitting and remove the trampoline.
15
16# CHECK: Binary Function "_start"
17# CHECK: IsSplit :
18# CHECK-SAME: 0
19
20## Check that a landing pad trampoline was created, but contains no instructions
21## and falls though to the real landing pad.
22
23# CHECK: {{^[^[:space:]]+}} (0 instructions
24# CHECK-NEXT: Landing Pad{{$}}
25# CHECK: Exec Count
26# CHECK-SAME: : 0
27# CHECK: Successors:
28# CHECK-SAME: [[LP:[^[:space:]]+]]
29# CHECK-EMPTY:
30# CHECK-NEXT: [[LP]]
31
32  .text
33	.global foo
34  .type foo, %function
35foo:
36  .cfi_startproc
37  ret
38  .cfi_endproc
39  .size foo, .-foo
40
41  .globl _start
42  .type _start, %function
43_start:
44# FDATA: 0 [unknown] 0 1 _start 0 1 100
45.Lfunc_begin0:
46  .cfi_startproc
47	.cfi_lsda 27, .Lexception0
48	call foo
49.Ltmp0:
50	call foo
51.Ltmp1:
52  ret
53
54## Cold landing pad.
55.LLP1:
56  ret
57
58## Hot landing pad.
59LLP0:
60# FDATA: 0 [unknown] 0 1 _start #LLP0# 1 100
61	ret
62
63  .cfi_endproc
64.Lfunc_end0:
65  .size _start, .-_start
66
67## EH table.
68	.section	.gcc_except_table,"a",@progbits
69	.p2align	2
70GCC_except_table0:
71.Lexception0:
72	.byte	255                             # @LPStart Encoding = omit
73	.byte	255                             # @TType Encoding = omit
74	.byte	1                               # Call site Encoding = uleb128
75	.uleb128 .Lcst_end0-.Lcst_begin0
76.Lcst_begin0:
77	.uleb128 .Lfunc_begin0-.Lfunc_begin0  # >> Call Site 1 <<
78	.uleb128 .Ltmp0-.Lfunc_begin0         #   Call between .Lfunc_begin0 and .Ltmp0
79	.uleb128 LLP0-.Lfunc_begin0					#   jumps to LLP0
80	.byte	0                               #   On action: cleanup
81	.uleb128 .Ltmp0-.Lfunc_begin0         # >> Call Site 2 <<
82	.uleb128 .Ltmp1-.Ltmp0                #   Call between .Ltmp0 and .Ltmp1
83	.uleb128 .LLP1-.Lfunc_begin0          #     jumps to .LLP1
84	.byte	0                               #   On action: cleanup
85.Lcst_end0:
86
87