A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Pulley: Only return exception registers for supported calling conventions (#12325)
Nick Fitzgerald54c1192eed26
diff --git a/cranelift/codegen/src/isa/pulley_shared/abi.rs b/cranelift/codegen/src/isa/pulley_shared/abi.rsindex de32099a14..8032e481c3 100644--- a/cranelift/codegen/src/isa/pulley_shared/abi.rs+++ b/cranelift/codegen/src/isa/pulley_shared/abi.rs@@ -560,12 +560,21 @@ whereWritable::from_reg(regs::x_reg(15))}- fn exception_payload_regs(_call_conv: isa::CallConv) -> &'static [Reg] {+ fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {const PAYLOAD_REGS: &'static [Reg] = &[Reg::from_real_reg(regs::px_reg(0)),Reg::from_real_reg(regs::px_reg(1)),];- PAYLOAD_REGS+ match call_conv {+ isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {+ PAYLOAD_REGS+ }+ isa::CallConv::Fast+ | isa::CallConv::WindowsFastcall+ | isa::CallConv::AppleAarch64+ | isa::CallConv::Probestack+ | isa::CallConv::Winch => &[],+ }}}diff --git a/cranelift/filetests/filetests/isa/pulley64/issue-12317.clif b/cranelift/filetests/filetests/isa/pulley64/issue-12317.clifnew file mode 100644index 0000000000..3696ef20e8--- /dev/null+++ b/cranelift/filetests/filetests/isa/pulley64/issue-12317.clif@@ -0,0 +1,19 @@+test compile+target pulley64++function %trigger_bug(i32) -> i32 {+ sig0 = (i32) -> i32 winch+ fn0 = %callee(i32) -> i32 winch++ block0(v0: i32):+ ; try_call triggers the bug by invoking exception handling codegen+ ; Note: We omit exn0 because exception_payload_types is empty+ try_call fn0(v0), sig0, block1(ret0), [ default: block2 ]++ block1(v1: i32):+ return v1++ block2:+ v3 = iconst.i32 -1+ return v3+}