xref: /llvm-project/llvm/test/CodeGen/Mips/mips16ex.ll (revision cfc1a8787829623ad7427bb7e71f380f6d241262)
1; RUN: llc  -mtriple=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
2
3;16: main:
4;16-NEXT: [[TMP:.*]]:
5;16-NEXT: .set $func_begin0, ([[TMP]])
6;16-NEXT: .cfi_startproc
7;16-NEXT: .cfi_personality
8@.str = private unnamed_addr constant [7 x i8] c"hello\0A\00", align 1
9@_ZTIi = external constant ptr
10@.str1 = private unnamed_addr constant [15 x i8] c"exception %i \0A\00", align 1
11
12define i32 @main() personality ptr @__gxx_personality_v0 {
13entry:
14  %retval = alloca i32, align 4
15  %exn.slot = alloca ptr
16  %ehselector.slot = alloca i32
17  %e = alloca i32, align 4
18  store i32 0, ptr %retval
19  %call = call i32 (ptr, ...) @printf(ptr @.str)
20  %exception = call ptr @__cxa_allocate_exception(i32 4) nounwind
21  store i32 20, ptr %exception
22  invoke void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) noreturn
23          to label %unreachable unwind label %lpad
24
25lpad:                                             ; preds = %entry
26  %0 = landingpad { ptr, i32 }
27          catch ptr @_ZTIi
28  %1 = extractvalue { ptr, i32 } %0, 0
29  store ptr %1, ptr %exn.slot
30  %2 = extractvalue { ptr, i32 } %0, 1
31  store i32 %2, ptr %ehselector.slot
32  br label %catch.dispatch
33
34catch.dispatch:                                   ; preds = %lpad
35  %sel = load i32, ptr %ehselector.slot
36  %3 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) nounwind
37  %matches = icmp eq i32 %sel, %3
38  br i1 %matches, label %catch, label %eh.resume
39
40catch:                                            ; preds = %catch.dispatch
41  %exn = load ptr, ptr %exn.slot
42  %4 = call ptr @__cxa_begin_catch(ptr %exn) nounwind
43  %exn.scalar = load i32, ptr %4
44  store i32 %exn.scalar, ptr %e, align 4
45  %5 = load i32, ptr %e, align 4
46  %call2 = invoke i32 (ptr, ...) @printf(ptr @.str1, i32 %5)
47          to label %invoke.cont unwind label %lpad1
48
49invoke.cont:                                      ; preds = %catch
50  call void @__cxa_end_catch() nounwind
51  br label %try.cont
52
53try.cont:                                         ; preds = %invoke.cont
54  ret i32 0
55
56lpad1:                                            ; preds = %catch
57  %6 = landingpad { ptr, i32 }
58          cleanup
59  %7 = extractvalue { ptr, i32 } %6, 0
60  store ptr %7, ptr %exn.slot
61  %8 = extractvalue { ptr, i32 } %6, 1
62  store i32 %8, ptr %ehselector.slot
63  call void @__cxa_end_catch() nounwind
64  br label %eh.resume
65
66eh.resume:                                        ; preds = %lpad1, %catch.dispatch
67  %exn3 = load ptr, ptr %exn.slot
68  %sel4 = load i32, ptr %ehselector.slot
69  %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn3, 0
70  %lpad.val5 = insertvalue { ptr, i32 } %lpad.val, i32 %sel4, 1
71  resume { ptr, i32 } %lpad.val5
72
73unreachable:                                      ; preds = %entry
74  unreachable
75}
76
77declare i32 @printf(ptr, ...)
78
79declare ptr @__cxa_allocate_exception(i32)
80
81declare i32 @__gxx_personality_v0(...)
82
83declare void @__cxa_throw(ptr, ptr, ptr)
84
85declare i32 @llvm.eh.typeid.for(ptr) nounwind readnone
86
87declare ptr @__cxa_begin_catch(ptr)
88
89declare void @__cxa_end_catch()
90