1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32I
4 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64I
7 ; Before getExceptionPointerRegister() and getExceptionSelectorRegister()
8 ; lowering hooks were defined this would trigger an assertion during live
11 declare void @foo(ptr %p);
12 declare void @bar(ptr %p);
13 declare dso_local i32 @__gxx_personality_v0(...)
15 define void @caller(ptr %p) personality ptr @__gxx_personality_v0 {
16 ; RV32I-LABEL: caller:
17 ; RV32I: # %bb.0: # %entry
18 ; RV32I-NEXT: addi sp, sp, -16
19 ; RV32I-NEXT: .cfi_def_cfa_offset 16
20 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
21 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
22 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
23 ; RV32I-NEXT: .cfi_offset ra, -4
24 ; RV32I-NEXT: .cfi_offset s0, -8
25 ; RV32I-NEXT: .cfi_offset s1, -12
26 ; RV32I-NEXT: .cfi_remember_state
27 ; RV32I-NEXT: mv s0, a0
28 ; RV32I-NEXT: beqz a0, .LBB0_2
29 ; RV32I-NEXT: # %bb.1: # %bb2
31 ; RV32I-NEXT: mv a0, s0
32 ; RV32I-NEXT: call bar
34 ; RV32I-NEXT: j .LBB0_3
35 ; RV32I-NEXT: .LBB0_2: # %bb1
37 ; RV32I-NEXT: mv a0, s0
38 ; RV32I-NEXT: call foo
40 ; RV32I-NEXT: .LBB0_3: # %end2
41 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
42 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
43 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
44 ; RV32I-NEXT: .cfi_restore ra
45 ; RV32I-NEXT: .cfi_restore s0
46 ; RV32I-NEXT: .cfi_restore s1
47 ; RV32I-NEXT: addi sp, sp, 16
48 ; RV32I-NEXT: .cfi_def_cfa_offset 0
50 ; RV32I-NEXT: .LBB0_4: # %lpad
51 ; RV32I-NEXT: .cfi_restore_state
53 ; RV32I-NEXT: mv s1, a0
54 ; RV32I-NEXT: mv a0, s0
55 ; RV32I-NEXT: call callee
56 ; RV32I-NEXT: mv a0, s1
57 ; RV32I-NEXT: call _Unwind_Resume
59 ; RV64I-LABEL: caller:
60 ; RV64I: # %bb.0: # %entry
61 ; RV64I-NEXT: addi sp, sp, -32
62 ; RV64I-NEXT: .cfi_def_cfa_offset 32
63 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
64 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
65 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
66 ; RV64I-NEXT: .cfi_offset ra, -8
67 ; RV64I-NEXT: .cfi_offset s0, -16
68 ; RV64I-NEXT: .cfi_offset s1, -24
69 ; RV64I-NEXT: .cfi_remember_state
70 ; RV64I-NEXT: mv s0, a0
71 ; RV64I-NEXT: beqz a0, .LBB0_2
72 ; RV64I-NEXT: # %bb.1: # %bb2
74 ; RV64I-NEXT: mv a0, s0
75 ; RV64I-NEXT: call bar
77 ; RV64I-NEXT: j .LBB0_3
78 ; RV64I-NEXT: .LBB0_2: # %bb1
80 ; RV64I-NEXT: mv a0, s0
81 ; RV64I-NEXT: call foo
83 ; RV64I-NEXT: .LBB0_3: # %end2
84 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
85 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
86 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
87 ; RV64I-NEXT: .cfi_restore ra
88 ; RV64I-NEXT: .cfi_restore s0
89 ; RV64I-NEXT: .cfi_restore s1
90 ; RV64I-NEXT: addi sp, sp, 32
91 ; RV64I-NEXT: .cfi_def_cfa_offset 0
93 ; RV64I-NEXT: .LBB0_4: # %lpad
94 ; RV64I-NEXT: .cfi_restore_state
96 ; RV64I-NEXT: mv s1, a0
97 ; RV64I-NEXT: mv a0, s0
98 ; RV64I-NEXT: call callee
99 ; RV64I-NEXT: mv a0, s1
100 ; RV64I-NEXT: call _Unwind_Resume
102 %0 = icmp eq ptr %p, null
103 br i1 %0, label %bb1, label %bb2
106 invoke void @foo(ptr %p) to label %end1 unwind label %lpad
109 invoke void @bar(ptr %p) to label %end2 unwind label %lpad
112 %1 = landingpad { ptr, i32 } cleanup
113 call void @callee(ptr %p)
114 resume { ptr, i32 } %1
123 define internal void @callee(ptr %p) {
124 ; RV32I-LABEL: callee:
128 ; RV64I-LABEL: callee: