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