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
61
62; V9ABS-LABEL: main:
63; V9ABS:        .cfi_startproc
64; V9ABS:        .cfi_personality 0, __gxx_personality_v0
65; V9ABS:        .cfi_lsda 27,
66; V9ABS:        .cfi_def_cfa_register {{30|%fp}}
67; V9ABS:        .cfi_window_save
68; V9ABS:        .cfi_register 15, 31
69; V9ABS:        .section .gcc_except_table
70; V9ABS-NOT:    .section
71; V9ABS:        .xword _ZTIi
72
73; V9PIC-LABEL: main:
74; V9PIC:        .cfi_startproc
75; V9PIC:        .cfi_personality 155, DW.ref.__gxx_personality_v0
76; V9PIC:        .cfi_lsda 27,
77; V9PIC:        .cfi_def_cfa_register {{30|%fp}}
78; V9PIC:        .cfi_window_save
79; V9PIC:        .cfi_register 15, 31
80; V9PIC:        .section .gcc_except_table
81; V9PIC-NOT:    .section
82; V9PIC:        .word %r_disp32(.L_ZTIi.DW.stub)
83; V9PIC:        .data
84; V9PIC: .L_ZTIi.DW.stub:
85; V9PIC-NEXT:   .xword _ZTIi
86
87; V9PIC_NOCFI-LABEL: main:
88; V9PIC_NOCFI:        .section .gcc_except_table
89; V9PIC_NOCFI-NOT:    .section
90; V9PIC_NOCFI:        .word %r_disp32(.L_ZTIi.DW.stub)
91; V9PIC_NOCFI:        .data
92; V9PIC_NOCFI: .L_ZTIi.DW.stub:
93; V9PIC_NOCFI-NEXT:   .xword _ZTIi
94; V9PIC_NOCFI:        .section .eh_frame
95; V9PIC_NOCFI-NOT:    .section
96; V9PIC_NOCFI:        .word %r_disp32(DW.ref.__gxx_personality_v0)
97
98define i32 @main(i32 %argc, i8** nocapture readnone %argv) unnamed_addr #0 {
99entry:
100  %0 = icmp eq i32 %argc, 2
101  %1 = tail call i8* @__cxa_allocate_exception(i32 4) #1
102  br i1 %0, label %"3", label %"4"
103
104"3":                                              ; preds = %entry
105  %2 = bitcast i8* %1 to i32*
106  store i32 0, i32* %2, align 4
107  invoke void @__cxa_throw(i8* %1, i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIi to i8*), void (i8*)* null) #2
108          to label %3 unwind label %"8"
109
110; <label>:3                                       ; preds = %"3"
111  unreachable
112
113"4":                                              ; preds = %entry
114  %4 = bitcast i8* %1 to float*
115  store float 1.000000e+00, float* %4, align 4
116
117
118  invoke void @__cxa_throw(i8* %1, i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIf to i8*), void (i8*)* null) #2
119          to label %5 unwind label %"8"
120
121; <label>:5                                       ; preds = %"4"
122  unreachable
123
124"5":                                              ; preds = %"13", %"11"
125  %6 = phi i32 [ 2, %"13" ], [ 0, %"11" ]
126  ret i32 %6
127
128"8":                                              ; preds = %"4", %"3"
129  %exc = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
130          catch %struct.__fundamental_type_info_pseudo* @_ZTIi
131          catch %struct.__fundamental_type_info_pseudo* @_ZTIf
132  %exc_ptr12 = extractvalue { i8*, i32 } %exc, 0
133  %filter13 = extractvalue { i8*, i32 } %exc, 1
134  %typeid = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIi to i8*))
135  %7 = icmp eq i32 %filter13, %typeid
136  br i1 %7, label %"11", label %8
137
138; <label>:8                                       ; preds = %"8"
139  %typeid8 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%struct.__fundamental_type_info_pseudo* @_ZTIf to i8*))
140  %9 = icmp eq i32 %filter13, %typeid8
141  br i1 %9, label %"13", label %"9"
142
143"9":                                              ; preds = %8
144  resume { i8*, i32 } %exc
145
146"11":                                             ; preds = %"8"
147  %10 = tail call i8* @__cxa_begin_catch(i8* %exc_ptr12) #1
148  %11 = tail call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.cst, i32 0, i32 0))
149  tail call void @__cxa_end_catch() #1
150  br label %"5"
151
152"13":                                             ; preds = %8
153  %12 = tail call i8* @__cxa_begin_catch(i8* %exc_ptr12) #1
154  %13 = tail call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.cst1, i32 0, i32 0))
155  tail call void @__cxa_end_catch() #1
156  br label %"5"
157}
158
159; Function Attrs: nounwind
160declare i8* @__cxa_allocate_exception(i32) #1
161
162; Function Attrs: noreturn
163declare void @__cxa_throw(i8*, i8*, void (i8*)*) #2
164
165declare void @__cxa_end_catch()
166
167; Function Attrs: nounwind readnone
168declare i32 @llvm.eh.typeid.for(i8*) #3
169
170; Function Attrs: nounwind
171declare i8* @__cxa_begin_catch(i8*) #1
172
173; Function Attrs: nounwind
174declare i32 @puts(i8* nocapture readonly) #1
175
176declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*)
177
178attributes #0 = { "no-frame-pointer-elim-non-leaf"="false" }
179attributes #1 = { nounwind }
180attributes #2 = { noreturn }
181attributes #3 = { nounwind readnone }
182