1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefix=LA32
4 ; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s --check-prefix=LA64
7 declare void @foo(ptr %p);
8 declare void @bar(ptr %p);
9 declare dso_local i32 @__gxx_personality_v0(...)
11 ;; Before getExceptionPointerRegister() and getExceptionSelectorRegister()
12 ;; lowering hooks were defined this would trigger an assertion during live
15 define void @caller(ptr %p) personality ptr @__gxx_personality_v0 {
17 ; LA32: # %bb.0: # %entry
18 ; LA32-NEXT: addi.w $sp, $sp, -16
19 ; LA32-NEXT: .cfi_def_cfa_offset 16
20 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
21 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
22 ; LA32-NEXT: st.w $s0, $sp, 4 # 4-byte Folded Spill
23 ; LA32-NEXT: .cfi_offset 1, -4
24 ; LA32-NEXT: .cfi_offset 22, -8
25 ; LA32-NEXT: .cfi_offset 23, -12
26 ; LA32-NEXT: move $fp, $a0
27 ; LA32-NEXT: beqz $a0, .LBB0_2
28 ; LA32-NEXT: # %bb.1: # %bb2
30 ; LA32-NEXT: move $a0, $fp
31 ; LA32-NEXT: bl %plt(bar)
33 ; LA32-NEXT: b .LBB0_3
34 ; LA32-NEXT: .LBB0_2: # %bb1
36 ; LA32-NEXT: move $a0, $fp
37 ; LA32-NEXT: bl %plt(foo)
39 ; LA32-NEXT: .LBB0_3: # %end2
40 ; LA32-NEXT: ld.w $s0, $sp, 4 # 4-byte Folded Reload
41 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
42 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
43 ; LA32-NEXT: addi.w $sp, $sp, 16
45 ; LA32-NEXT: .LBB0_4: # %lpad
47 ; LA32-NEXT: move $s0, $a0
48 ; LA32-NEXT: move $a0, $fp
49 ; LA32-NEXT: bl callee
50 ; LA32-NEXT: move $a0, $s0
51 ; LA32-NEXT: bl %plt(_Unwind_Resume)
54 ; LA64: # %bb.0: # %entry
55 ; LA64-NEXT: addi.d $sp, $sp, -32
56 ; LA64-NEXT: .cfi_def_cfa_offset 32
57 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
58 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
59 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
60 ; LA64-NEXT: .cfi_offset 1, -8
61 ; LA64-NEXT: .cfi_offset 22, -16
62 ; LA64-NEXT: .cfi_offset 23, -24
63 ; LA64-NEXT: move $fp, $a0
64 ; LA64-NEXT: beqz $a0, .LBB0_2
65 ; LA64-NEXT: # %bb.1: # %bb2
67 ; LA64-NEXT: move $a0, $fp
68 ; LA64-NEXT: bl %plt(bar)
70 ; LA64-NEXT: b .LBB0_3
71 ; LA64-NEXT: .LBB0_2: # %bb1
73 ; LA64-NEXT: move $a0, $fp
74 ; LA64-NEXT: bl %plt(foo)
76 ; LA64-NEXT: .LBB0_3: # %end2
77 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
78 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
79 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
80 ; LA64-NEXT: addi.d $sp, $sp, 32
82 ; LA64-NEXT: .LBB0_4: # %lpad
84 ; LA64-NEXT: move $s0, $a0
85 ; LA64-NEXT: move $a0, $fp
86 ; LA64-NEXT: bl callee
87 ; LA64-NEXT: move $a0, $s0
88 ; LA64-NEXT: bl %plt(_Unwind_Resume)
90 %0 = icmp eq ptr %p, null
91 br i1 %0, label %bb1, label %bb2
94 invoke void @foo(ptr %p) to label %end1 unwind label %lpad
97 invoke void @bar(ptr %p) to label %end2 unwind label %lpad
100 %1 = landingpad { ptr, i32 } cleanup
101 call void @callee(ptr %p)
102 resume { ptr, i32 } %1
111 define internal void @callee(ptr %p) {
112 ; LA32-LABEL: callee:
116 ; LA64-LABEL: callee: