xref: /llvm-project/llvm/test/CodeGen/X86/gnu-eh-alternative.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; RUN: llc -verify-machineinstrs -mtriple x86_64-pc-linux-gnu -filetype=asm < %s | \
2; RUN:   FileCheck --check-prefixes=ASM,ULEB128 %s
3; RUN: llc -verify-machineinstrs -mtriple x86_64-pc-linux-gnu -use-leb128-directives=true -filetype=asm < %s | \
4; RUN:   FileCheck --check-prefixes=ASM,ULEB128 %s
5; RUN: llc -verify-machineinstrs -mtriple x86_64-pc-linux-gnu -use-leb128-directives=false -filetype=asm < %s | \
6; RUN:   FileCheck --check-prefixes=ASM,NO128 %s
7
8@_ZTIi = external dso_local constant ptr
9
10define dso_local i32 @main() personality ptr @__gxx_personality_v0 {
11entry:
12  %retval = alloca i32, align 4
13  %exn.slot = alloca ptr, align 8
14  %ehselector.slot = alloca i32, align 4
15  store i32 0, ptr %retval, align 4
16  %exception = call ptr @__cxa_allocate_exception(i64 4) #1
17  store i32 1, ptr %exception, align 16
18  invoke void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #2
19          to label %unreachable unwind label %lpad
20
21lpad:                                             ; preds = %entry
22  %0 = landingpad { ptr, i32 }
23          catch ptr null
24  %1 = extractvalue { ptr, i32 } %0, 0
25  store ptr %1, ptr %exn.slot, align 8
26  %2 = extractvalue { ptr, i32 } %0, 1
27  store i32 %2, ptr %ehselector.slot, align 4
28  br label %catch
29
30catch:                                            ; preds = %lpad
31  %exn = load ptr, ptr %exn.slot, align 8
32  %3 = call ptr @__cxa_begin_catch(ptr %exn) #1
33  store i32 2, ptr %retval, align 4
34  call void @__cxa_end_catch()
35  br label %return
36
37try.cont:                                         ; No predecessors!
38  store i32 1, ptr %retval, align 4
39  br label %return
40
41return:                                           ; preds = %try.cont, %catch
42  %4 = load i32, ptr %retval, align 4
43  ret i32 %4
44
45unreachable:                                      ; preds = %entry
46  unreachable
47}
48
49; ASM:     GCC_except_table0:
50; ASM:     .Lexception0:
51; ASM:     	.byte	255                             # @LPStart Encoding = omit
52; ASM:     	.byte	3                               # @TType Encoding = udata4
53
54; NO128:   	.byte	49
55; NO128:   	.byte	3                               # Call site Encoding = udata4
56; NO128:   	.byte	39
57; NO128:    .long	.Lfunc_begin0-.Lfunc_begin0     # >> Call Site 1 <<
58; NO128:    .long	.Ltmp0-.Lfunc_begin0            #   Call between .Lfunc_begin0 and .Ltmp0
59; NO128:    .long	0                               #     has no landing pad
60; NO128:    .byte	0                               #   On action: cleanup
61; NO128:    .long	.Ltmp0-.Lfunc_begin0            # >> Call Site 2 <<
62; NO128:    .long	.Ltmp1-.Ltmp0                   #   Call between .Ltmp0 and .Ltmp1
63; NO128:    .long	.Ltmp2-.Lfunc_begin0            #     jumps to .Ltmp2
64; NO128:    .byte	1                               #   On action: 1
65; NO128:    .long	.Ltmp1-.Lfunc_begin0            # >> Call Site 3 <<
66; NO128:    .long	.Lfunc_end0-.Ltmp1              #   Call between .Ltmp1 and .Lfunc_end0
67; NO128:    .long	0                               #     has no landing pad
68; NO128:    .byte	0                               #   On action: cleanup
69
70; ULEB128: 	.uleb128 .Lttbase0-.Lttbaseref0
71; ULEB128: .Lttbaseref0:
72; ULEB128: 	.byte	1                               # Call site Encoding = uleb128
73; ULEB128: 	.uleb128 .Lcst_end0-.Lcst_begin0
74; ULEB128: .Lcst_begin0:
75; ULEB128: 	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
76; ULEB128: 	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
77; ULEB128: 	.byte	0                               #     has no landing pad
78; ULEB128: 	.byte	0                               #   On action: cleanup
79; ULEB128: 	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
80; ULEB128: 	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
81; ULEB128: 	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
82; ULEB128: 	.byte	1                               #   On action: 1
83; ULEB128: 	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
84; ULEB128: 	.uleb128 .Lfunc_end0-.Ltmp1             #   Call between .Ltmp1 and .Lfunc_end0
85; ULEB128: 	.byte	0                               #     has no landing pad
86; ULEB128: 	.byte	0                               #   On action: cleanup
87
88; ASM:     .Lcst_end0:
89; ASM:     	.byte	1                               # >> Action Record 1 <<
90; ASM:                                             #   Catch TypeInfo 1
91; ASM:     	.byte	0                               #   No further actions
92; ASM:     	.p2align	2
93; ASM:                                             # >> Catch TypeInfos <<
94; ASM:     	.long	0                               # TypeInfo 1
95; ASM:     .Lttbase0:
96; ASM:     	.p2align	2
97
98declare dso_local ptr @__cxa_allocate_exception(i64)
99declare dso_local void @__cxa_throw(ptr, ptr, ptr)
100declare dso_local i32 @__gxx_personality_v0(...)
101declare dso_local ptr @__cxa_begin_catch(ptr)
102declare dso_local void @__cxa_end_catch()
103