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: mv s0, a0
27 ; RV32I-NEXT: beqz a0, .LBB0_2
28 ; RV32I-NEXT: # %bb.1: # %bb2
30 ; RV32I-NEXT: mv a0, s0
31 ; RV32I-NEXT: call bar
33 ; RV32I-NEXT: j .LBB0_3
34 ; RV32I-NEXT: .LBB0_2: # %bb1
36 ; RV32I-NEXT: mv a0, s0
37 ; RV32I-NEXT: call foo
39 ; RV32I-NEXT: .LBB0_3: # %end2
40 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
41 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
42 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
43 ; RV32I-NEXT: addi sp, sp, 16
45 ; RV32I-NEXT: .LBB0_4: # %lpad
47 ; RV32I-NEXT: mv s1, a0
48 ; RV32I-NEXT: mv a0, s0
49 ; RV32I-NEXT: call callee
50 ; RV32I-NEXT: mv a0, s1
51 ; RV32I-NEXT: call _Unwind_Resume
53 ; RV64I-LABEL: caller:
54 ; RV64I: # %bb.0: # %entry
55 ; RV64I-NEXT: addi sp, sp, -32
56 ; RV64I-NEXT: .cfi_def_cfa_offset 32
57 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
58 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
59 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
60 ; RV64I-NEXT: .cfi_offset ra, -8
61 ; RV64I-NEXT: .cfi_offset s0, -16
62 ; RV64I-NEXT: .cfi_offset s1, -24
63 ; RV64I-NEXT: mv s0, a0
64 ; RV64I-NEXT: beqz a0, .LBB0_2
65 ; RV64I-NEXT: # %bb.1: # %bb2
67 ; RV64I-NEXT: mv a0, s0
68 ; RV64I-NEXT: call bar
70 ; RV64I-NEXT: j .LBB0_3
71 ; RV64I-NEXT: .LBB0_2: # %bb1
73 ; RV64I-NEXT: mv a0, s0
74 ; RV64I-NEXT: call foo
76 ; RV64I-NEXT: .LBB0_3: # %end2
77 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
78 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
79 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
80 ; RV64I-NEXT: addi sp, sp, 32
82 ; RV64I-NEXT: .LBB0_4: # %lpad
84 ; RV64I-NEXT: mv s1, a0
85 ; RV64I-NEXT: mv a0, s0
86 ; RV64I-NEXT: call callee
87 ; RV64I-NEXT: mv a0, s1
88 ; RV64I-NEXT: call _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 ; RV32I-LABEL: callee:
116 ; RV64I-LABEL: callee: