2e2f9a451ed1b5a472c2ffe5a3f27d5467a1e09e
[oota-llvm.git] / test / CodeGen / Mips / eh.ll
1 ; RUN: llc  < %s -march=mipsel | FileCheck %s -check-prefix=CHECK-EL
2 ; RUN: llc  < %s -march=mips   | FileCheck %s -check-prefix=CHECK-EB
3
4 @g1 = global double 0.000000e+00, align 8
5 @_ZTId = external constant i8*
6
7 define void @_Z1fd(double %i2) {
8 entry:
9 ; CHECK-EL:  addiu $sp, $sp
10 ; CHECK-EL:  .cfi_def_cfa_offset
11 ; CHECK-EL:  sdc1 $f20
12 ; CHECK-EL:  sw  $ra
13 ; CHECK-EL:  .cfi_offset 52, -8
14 ; CHECK-EL:  .cfi_offset 53, -4
15 ; CHECK-EB:  .cfi_offset 53, -8
16 ; CHECK-EB:  .cfi_offset 52, -4
17 ; CHECK-EL:  .cfi_offset 31, -12
18 ; CHECK-EL:  .cprestore 
19
20   %exception = tail call i8* @__cxa_allocate_exception(i32 8) nounwind
21   %0 = bitcast i8* %exception to double*
22   store double 3.200000e+00, double* %0, align 8, !tbaa !0
23   invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTId to i8*), i8* null) noreturn
24           to label %unreachable unwind label %lpad
25
26 lpad:                                             ; preds = %entry
27 ; CHECK-EL:  # %lpad
28 ; CHECK-EL:  lw  $gp
29 ; CHECK-EL:  bne $5
30
31   %exn.val = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
32            catch i8* bitcast (i8** @_ZTId to i8*)
33   %exn = extractvalue { i8*, i32 } %exn.val, 0
34   %sel = extractvalue { i8*, i32 } %exn.val, 1
35   %1 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) nounwind
36   %2 = icmp eq i32 %sel, %1
37   br i1 %2, label %catch, label %eh.resume
38
39 catch:                                            ; preds = %lpad
40   %3 = tail call i8* @__cxa_begin_catch(i8* %exn) nounwind
41   %4 = bitcast i8* %3 to double*
42   %exn.scalar = load double* %4, align 8
43   %add = fadd double %exn.scalar, %i2
44   store double %add, double* @g1, align 8, !tbaa !0
45   tail call void @__cxa_end_catch() nounwind
46   ret void
47
48 eh.resume:                                        ; preds = %lpad
49   resume { i8*, i32 } %exn.val
50
51 unreachable:                                      ; preds = %entry
52   unreachable
53 }
54
55 declare i8* @__cxa_allocate_exception(i32)
56
57 declare i32 @__gxx_personality_v0(...)
58
59 declare i32 @llvm.eh.typeid.for(i8*) nounwind
60
61 declare void @__cxa_throw(i8*, i8*, i8*)
62
63 declare i8* @__cxa_begin_catch(i8*)
64
65 declare void @__cxa_end_catch()
66
67 !0 = metadata !{metadata !"double", metadata !1}
68 !1 = metadata !{metadata !"omnipotent char", metadata !2}
69 !2 = metadata !{metadata !"Simple C/C++ TBAA", null}