xref: /llvm-project/bolt/test/runtime/X86/exceptions-lpstart-zero.s (revision 84602066a6be175513880283394268b0f29eb296)
1# RUN: %clangxx %cflags -no-pie %s -o %t.exe -Wl,-q
2# RUN: llvm-bolt %t.exe -o %t.exe.bolt
3# RUN: %t.exe.bolt
4
5# REQUIRES: system-linux
6
7## Test that BOLT properly handles LPStart when LPStartEncoding is different
8## from DW_EH_PE_omit.
9
10# The test case compiled with -O1 from:
11#
12# int main() {
13#   try {
14#     throw 42;
15#   } catch (...) {
16#     return 0;
17#   }
18#   return 1;
19# }
20#
21# The exception table was modified with udata4 LPStartEncoding and sdata4
22# CallSiteEncoding.
23
24	.text
25	.globl	main                            # -- Begin function main
26	.p2align	4, 0x90
27	.type	main,@function
28main:                                   # @main
29.Lfunc_begin0:
30	.cfi_startproc
31	.cfi_personality 3, __gxx_personality_v0
32	.cfi_lsda 3, .Lexception0
33# %bb.0:
34	pushq	%rax
35	.cfi_def_cfa_offset 16
36	movl	$4, %edi
37	callq	__cxa_allocate_exception
38	movl	$42, (%rax)
39.Ltmp0:
40	movl	$_ZTIi, %esi
41	movq	%rax, %rdi
42	xorl	%edx, %edx
43	callq	__cxa_throw
44.Ltmp1:
45# %bb.1:
46.LBB0_2:
47.Ltmp2:
48	movq	%rax, %rdi
49	callq	__cxa_begin_catch
50	callq	__cxa_end_catch
51	xorl	%eax, %eax
52	popq	%rcx
53	.cfi_def_cfa_offset 8
54	retq
55.Lfunc_end0:
56	.size	main, .Lfunc_end0-main
57	.cfi_endproc
58	.section	.gcc_except_table,"a",@progbits
59	.p2align	2
60GCC_except_table0:
61.Lexception0:
62	.byte	3                               # @LPStart Encoding = udata4
63  .long 0
64	.byte	3                               # @TType Encoding = udata4
65	.uleb128 .Lttbase0-.Lttbaseref0
66.Lttbaseref0:
67	.byte	11                              # Call site Encoding = sdata4
68	.uleb128 .Lcst_end0-.Lcst_begin0
69.Lcst_begin0:
70	.long .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
71	.long .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
72	.long	0                               #     has no landing pad
73	.byte	0                               #   On action: cleanup
74	.long .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
75	.long .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
76	.long .Ltmp2                         #     jumps to .Ltmp2
77	.byte	1                               #   On action: 1
78	.long .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
79	.long .Lfunc_end0-.Ltmp1             #   Call between .Ltmp1 and .Lfunc_end0
80	.long	0                               #     has no landing pad
81	.byte	0                               #   On action: cleanup
82.Lcst_end0:
83	.byte	1                               # >> Action Record 1 <<
84                                        #   Catch TypeInfo 1
85	.byte	0                               #   No further actions
86	.p2align	2
87                                        # >> Catch TypeInfos <<
88	.long	0                               # TypeInfo 1
89.Lttbase0:
90	.p2align	2
91                                        # -- End function
92