1; RUN: llc < %s -march=sparc   -relocation-model=static | FileCheck -check-prefix=V8ABS %s
2; RUN: llc < %s -march=sparc   -relocation-model=pic    | FileCheck -check-prefix=V8PIC %s
3; RUN: llc < %s -march=sparc   -relocation-model=pic -disable-cfi    | FileCheck -check-prefix=V8PIC_NOCFI %s
4; RUN: llc < %s -march=sparcv9 -relocation-model=static | FileCheck -check-prefix=V9ABS %s
5; RUN: llc < %s -march=sparcv9 -relocation-model=pic    | FileCheck -check-prefix=V9PIC %s
6; RUN: llc < %s -march=sparcv9 -relocation-model=pic -disable-cfi    | FileCheck -check-prefix=V9PIC_NOCFI %s
7
8
9%struct.__fundamental_type_info_pseudo = type { %struct.__type_info_pseudo }
10%struct.__type_info_pseudo = type { i8*, i8* }
11
12@_ZTIi = external constant %struct.__fundamental_type_info_pseudo
13@_ZTIf = external constant %struct.__fundamental_type_info_pseudo
14@.cst = linker_private unnamed_addr constant [12 x i8] c"catched int\00", align 64
15@.cst1 = linker_private unnamed_addr constant [14 x i8] c"catched float\00", align 64
16
17; V8ABS-LABEL: main:
18; V8ABS:        .cfi_startproc
19; V8ABS:        .cfi_personality 0, __gxx_personality_v0
20; V8ABS:        .cfi_lsda 0,
21; V8ABS:        .cfi_def_cfa_register {{30|%fp}}
22; V8ABS:        .cfi_window_save
23; V8ABS:        .cfi_register 15, 31
24
25; V8ABS:        call __cxa_throw
26; V8ABS:        call __cxa_throw
27
28; V8ABS:        call __cxa_begin_catch
29; V8ABS:        call __cxa_end_catch
30
31; V8ABS:        call __cxa_begin_catch
32; V8ABS:        call __cxa_end_catch
33
34; V8ABS:        .cfi_endproc
35
36; V8PIC-LABEL: main:
37; V8PIC:        .cfi_startproc
38; V8PIC:        .cfi_personality 155, DW.ref.__gxx_personality_v0
39; V8PIC:        .cfi_lsda 27,
40; V8PIC:        .cfi_def_cfa_register {{30|%fp}}
41; V8PIC:        .cfi_window_save
42; V8PIC:        .cfi_register 15, 31
43; V8PIC:        .section .gcc_except_table
44; V8PIC-NOT:    .section
45; V8PIC:        .word %r_disp32(.L_ZTIi.DW.stub)
46; V8PIC:        .data
47; V8PIC: .L_ZTIi.DW.stub:
48; V8PIC-NEXT:   .word _ZTIi
49
50; V8PIC_NOCFI-LABEL: main:
51; V8PIC_NOCFI:        .section .gcc_except_table
52; V8PIC_NOCFI-NOT:    .section
53; V8PIC_NOCFI:        .word %r_disp32(.L_ZTIi.DW.stub)
54; V8PIC_NOCFI:        .data
55; V8PIC_NOCFI: .L_ZTIi.DW.stub:
56; V8PIC_NOCFI-NEXT:   .word _ZTIi
57; V8PIC_NOCFI:        .section .eh_frame
58; V8PIC_NOCFI-NOT:    .section
59; V8PIC_NOCFI:        .word %r_disp32(DW.ref.__gxx_personality_v0)
60; V8PIC_NOCFI:        .word %r_disp32(.Ltmp{{.+}}) ! FDE initial location
61
62
63; V9ABS-LABEL: main:
64; V9ABS:        .cfi_startproc
65; V9ABS:        .cfi_personality 0, __gxx_personality_v0
66; V9ABS:        .cfi_lsda 27,
67; V9ABS:        .cfi_def_cfa_register {{30|%fp}}
68; V9ABS:        .cfi_window_save
69; V9ABS:        .cfi_register 15, 31
70; V9ABS:        .section .gcc_except_table
71; V9ABS-NOT:    .section
72; V9ABS:        .xword _ZTIi
73
74; V9PIC-LABEL: main:
75; V9PIC:        .cfi_startproc
76; V9PIC:        .cfi_personality 155, DW.ref.__gxx_personality_v0
77; V9PIC:        .cfi_lsda 27,
78; V9PIC:        .cfi_def_cfa_register {{30|%fp}}
79; V9PIC:        .cfi_window_save
80; V9PIC:        .cfi_register 15, 31
81; V9PIC:        .section .gcc_except_table
82; V9PIC-NOT:    .section
83; V9PIC:        .word %r_disp32(.L_ZTIi.DW.stub)
84; V9PIC:        .data
85; V9PIC: .L_ZTIi.DW.stub:
86; V9PIC-NEXT:   .xword _ZTIi
87
88; V9PIC_NOCFI-LABEL: main:
89; V9PIC_NOCFI:        .section .gcc_except_table
90; V9PIC_NOCFI-NOT:    .section
91; V9PIC_NOCFI:        .word %r_disp32(.L_ZTIi.DW.stub)
92; V9PIC_NOCFI:        .data
93; V9PIC_NOCFI: .L_ZTIi.DW.stub:
94; V9PIC_NOCFI-NEXT:   .xword _ZTIi
95; V9PIC_NOCFI:        .section .eh_frame
96; V9PIC_NOCFI-NOT:    .section
97; V9PIC_NOCFI:        .word %r_disp32(DW.ref.__gxx_personality_v0)
98; V9PIC_NOCFI:        .word %r_disp32(.Ltmp{{.+}}) ! FDE initial location
99
100define i32 @main(i32 %argc, i8** nocapture readnone %argv) unnamed_addr #0 {
101entry:
102  %0 = icmp eq i32 %argc, 2
103  %1 = tail call i8* @__cxa_allocate_exception(i32 4) #1
104  br i1 %0, label %"3", label %"4"
105
106"3":                                              ; preds = %entry
107  %2 = bitcast i8* %1 to i32*
108  store i32 0, i32* %2, align 4
109  invoke void @__cxa_throw(i8* %1, i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIi to i8*), void (i8*)* null) #2
110          to label %3 unwind label %"8"
111
112; <label>:3                                       ; preds = %"3"
113  unreachable
114
115"4":                                              ; preds = %entry
116  %4 = bitcast i8* %1 to float*
117  store float 1.000000e+00, float* %4, align 4
118
119
120  invoke void @__cxa_throw(i8* %1, i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIf to i8*), void (i8*)* null) #2
121          to label %5 unwind label %"8"
122
123; <label>:5                                       ; preds = %"4"
124  unreachable
125
126"5":                                              ; preds = %"13", %"11"
127  %6 = phi i32 [ 2, %"13" ], [ 0, %"11" ]
128  ret i32 %6
129
130"8":                                              ; preds = %"4", %"3"
131  %exc = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
132          catch %struct.__fundamental_type_info_pseudo* @_ZTIi
133          catch %struct.__fundamental_type_info_pseudo* @_ZTIf
134  %exc_ptr12 = extractvalue { i8*, i32 } %exc, 0
135  %filter13 = extractvalue { i8*, i32 } %exc, 1
136  %typeid = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIi to i8*))
137  %7 = icmp eq i32 %filter13, %typeid
138  br i1 %7, label %"11", label %8
139
140; <label>:8                                       ; preds = %"8"
141  %typeid8 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIf to i8*))
142  %9 = icmp eq i32 %filter13, %typeid8
143  br i1 %9, label %"13", label %"9"
144
145"9":                                              ; preds = %8
146  resume { i8*, i32 } %exc
147
148"11":                                             ; preds = %"8"
149  %10 = tail call i8* @__cxa_begin_catch(i8* %exc_ptr12) #1
150  %11 = tail call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.cst, i32 0, i32 0))
151  tail call void @__cxa_end_catch() #1
152  br label %"5"
153
154"13":                                             ; preds = %8
155  %12 = tail call i8* @__cxa_begin_catch(i8* %exc_ptr12) #1
156  %13 = tail call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.cst1, i32 0, i32 0))
157  tail call void @__cxa_end_catch() #1
158  br label %"5"
159}
160
161; Function Attrs: nounwind
162declare i8* @__cxa_allocate_exception(i32) #1
163
164; Function Attrs: noreturn
165declare void @__cxa_throw(i8*, i8*, void (i8*)*) #2
166
167declare void @__cxa_end_catch()
168
169; Function Attrs: nounwind readnone
170declare i32 @llvm.eh.typeid.for(i8*) #3
171
172; Function Attrs: nounwind
173declare i8* @__cxa_begin_catch(i8*) #1
174
175; Function Attrs: nounwind
176declare i32 @puts(i8* nocapture readonly) #1
177
178declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*)
179
180attributes #0 = { "no-frame-pointer-elim-non-leaf"="false" }
181attributes #1 = { nounwind }
182attributes #2 = { noreturn }
183attributes #3 = { nounwind readnone }
184