Skip to content

Commit 54c1192

Browse files
authored
Pulley: Only return exception registers for supported calling conventions (#12325)
Fixes #12317
1 parent 2196811 commit 54c1192

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

cranelift/codegen/src/isa/pulley_shared/abi.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,21 @@ where
560560
Writable::from_reg(regs::x_reg(15))
561561
}
562562

563-
fn exception_payload_regs(_call_conv: isa::CallConv) -> &'static [Reg] {
563+
fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {
564564
const PAYLOAD_REGS: &'static [Reg] = &[
565565
Reg::from_real_reg(regs::px_reg(0)),
566566
Reg::from_real_reg(regs::px_reg(1)),
567567
];
568-
PAYLOAD_REGS
568+
match call_conv {
569+
isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {
570+
PAYLOAD_REGS
571+
}
572+
isa::CallConv::Fast
573+
| isa::CallConv::WindowsFastcall
574+
| isa::CallConv::AppleAarch64
575+
| isa::CallConv::Probestack
576+
| isa::CallConv::Winch => &[],
577+
}
569578
}
570579
}
571580

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
test compile
2+
target pulley64
3+
4+
function %trigger_bug(i32) -> i32 {
5+
sig0 = (i32) -> i32 winch
6+
fn0 = %callee(i32) -> i32 winch
7+
8+
block0(v0: i32):
9+
; try_call triggers the bug by invoking exception handling codegen
10+
; Note: We omit exn0 because exception_payload_types is empty
11+
try_call fn0(v0), sig0, block1(ret0), [ default: block2 ]
12+
13+
block1(v1: i32):
14+
return v1
15+
16+
block2:
17+
v3 = iconst.i32 -1
18+
return v3
19+
}

0 commit comments

Comments
 (0)