Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Cranelift: make all non-tail, non-indirect calls patchable, and rename patchable ABI to `preserve_all`. (#12160)

Chris Fallin87ed3b6019ab
diff --git a/cranelift/codegen/meta/src/shared/instructions.rs b/cranelift/codegen/meta/src/shared/instructions.rs
index 8e1365dd85..9604c6904b 100644
--- a/cranelift/codegen/meta/src/shared/instructions.rs
+++ b/cranelift/codegen/meta/src/shared/instructions.rs
@@ -3918,31 +3918,4 @@ pub(crate) fn define(
)
.other_side_effects(),
);
-
- ig.push(
- Inst::new(
- "patchable_call",
- r#"
- A call instruction that can be turned on/off by patching machine code.
-
- This call is different than an ordinary call in a few ways:
- - It can only call functions with the `patchable` ABI.
- - As a result of that, the called function cannot have any
- return values.
- - The call emits metadata into the MachBuffer that allows the consumer
- of the machine code to edit the code to either make the call or not.
-
- Note that the lack of return values is necessary: because the call
- may or may not occur, dynamically, we cannot rely on any values
- actually being defined.
- "#,
- &formats.call,
- )
- .operands_in(vec![
- Operand::new("FN", &entities.func_ref)
- .with_doc("function to call, declared by `function`"),
- Operand::new("args", &entities.varargs).with_doc("call arguments"),
- ])
- .call(),
- );
}
diff --git a/cranelift/codegen/meta/src/shared/settings.rs b/cranelift/codegen/meta/src/shared/settings.rs
index 10d77ca692..b152b4d462 100644
--- a/cranelift/codegen/meta/src/shared/settings.rs
+++ b/cranelift/codegen/meta/src/shared/settings.rs
@@ -169,11 +169,11 @@ pub(crate) fn define() -> SettingGroup {
vec![
"isa_default",
"fast",
- "cold",
"system_v",
"windows_fastcall",
"apple_aarch64",
"probestack",
+ "preserve_all",
],
);
diff --git a/cranelift/codegen/src/inline.rs b/cranelift/codegen/src/inline.rs
index 4332012221..ac150c5989 100644
--- a/cranelift/codegen/src/inline.rs
+++ b/cranelift/codegen/src/inline.rs
@@ -139,6 +139,14 @@ pub(crate) fn do_inlining(
debug_assert_eq!(Some(block), cursor.func.layout.inst_block(inst));
match cursor.func.dfg.insts[inst] {
+ ir::InstructionData::Call { func_ref, .. }
+ if cursor.func.dfg.ext_funcs[func_ref].patchable =>
+ {
+ // Can't inline patchable calls; they need to
+ // remain patchable and inlining the whole body is
+ // decidedly *not* patchable!
+ }
+
ir::InstructionData::Call {
opcode: opcode @ ir::Opcode::Call | opcode @ ir::Opcode::ReturnCall,
args: _,
@@ -227,14 +235,6 @@ pub(crate) fn do_inlining(
// Can't inline indirect calls; need to have some earlier
// pass rewrite them into direct calls first, when possible.
}
- ir::InstructionData::Call {
- opcode: ir::Opcode::PatchableCall,
- ..
- } => {
- // Can't inline patchable calls; they need to
- // remain patchable and inlining the whole body is
- // decidedly *not* patchable!
- }
_ => {
debug_assert!(
!cursor.func.dfg.insts[inst].opcode().is_call(),
@@ -505,19 +505,7 @@ fn inline_one(
call_opcode == ir::Opcode::TryCall,
call_exception_table.is_some()
);
- // Note that we do not fix up patchable calls
- // inlined at a try-call to a try-call, because
- // the "patchable ABI" does not support catching
- // exceptions. This does mean that we cannot have
- // an exception-throw propagate out of a
- // breakpoint when we use patchable calls to set
- // up breakpoints, but we don't expect that to
- // occur.
- //
- // FIXME: consider making patchability an aspect
- // of any call; then we can remove this special
- // case.
- if call_opcode == ir::Opcode::TryCall && opcode != ir::Opcode::PatchableCall {
+ if call_opcode == ir::Opcode::TryCall {
allocs
.calls_needing_exception_table_fixup
.push(inlined_inst);
@@ -1491,6 +1479,7 @@ fn create_func_refs(
name,
signature,
colocated,
+ patchable,
} in callee.dfg.ext_funcs.values()
{
func.dfg.ext_funcs.push(ir::ExtFuncData {
@@ -1507,6 +1496,7 @@ fn create_func_refs(
},
signature: entity_map.inlined_sig_ref(*signature),
colocated: *colocated,
+ patchable: *patchable,
});
}
diff --git a/cranelift/codegen/src/inst_predicates.rs b/cranelift/codegen/src/inst_predicates.rs
index 60507594ba..7b42e17286 100644
--- a/cranelift/codegen/src/inst_predicates.rs
+++ b/cranelift/codegen/src/inst_predicates.rs
@@ -149,11 +149,7 @@ pub fn has_memory_fence_semantics(op: Opcode) -> bool {
| Opcode::Fence
| Opcode::Debugtrap
| Opcode::SequencePoint => true,
- Opcode::Call
- | Opcode::CallIndirect
- | Opcode::TryCall
- | Opcode::TryCallIndirect
- | Opcode::PatchableCall => true,
+ Opcode::Call | Opcode::CallIndirect | Opcode::TryCall | Opcode::TryCallIndirect => true,
op if op.can_trap() => true,
_ => false,
}
diff --git a/cranelift/codegen/src/ir/extfunc.rs b/cranelift/codegen/src/ir/extfunc.rs
index 821eb009dd..ebfaf3a8dd 100644
--- a/cranelift/codegen/src/ir/extfunc.rs
+++ b/cranelift/codegen/src/ir/extfunc.rs
@@ -313,6 +313,14 @@ pub struct ExtFuncData {
/// See the documentation for `RelocDistance` for more details. A `colocated` flag value of
/// `true` implies `RelocDistance::Near`.
pub colocated: bool,
+ /// Is this function "patchable"? If so, calls to this function will
+ /// emit additional metadata indicating how to patch them in or out.
+ ///
+ /// Calls to functions of any calling convention may be patchable,
+ /// *but* only calls with no return values are patchable. This is
+ /// because every SSA value must always be defined, and return
+ /// values would not be if the call were patched out.
+ pub patchable: bool,
}
impl ExtFuncData {
@@ -340,6 +348,9 @@ impl<'a> fmt::Display for DisplayableExtFuncData<'a> {
if self.ext_func.colocated {
write!(f, "colocated ")?;
}
+ if self.ext_func.patchable {
+ write!(f, "patchable ")?;
+ }
write!(
f,
"{} {}",
@@ -384,7 +395,8 @@ mod tests {
fn call_conv() {
for &cc in &[
CallConv::Fast,
- CallConv::Cold,
+ CallConv::PreserveAll,
+ CallConv::Tail,
CallConv::SystemV,
CallConv::WindowsFastcall,
] {
diff --git a/cranelift/codegen/src/isa/aarch64/abi.rs b/cranelift/codegen/src/isa/aarch64/abi.rs
index 1be4856fcc..20f8476a60 100644
--- a/cranelift/codegen/src/isa/aarch64/abi.rs
+++ b/cranelift/codegen/src/isa/aarch64/abi.rs
@@ -1067,6 +1067,7 @@ impl ABIMachineSpec for AArch64MachineDeps {
callee_conv: call_conv,
callee_pop_size: 0,
try_call_info: None,
+ patchable: false,
}),
});
insts
@@ -1101,8 +1102,14 @@ impl ABIMachineSpec for AArch64MachineDeps {
(isa::CallConv::Tail, true) => ALL_CLOBBERS,
(isa::CallConv::Winch, true) => ALL_CLOBBERS,
(isa::CallConv::Winch, false) => WINCH_CLOBBERS,
+ // Note that "PreserveAll" actually preserves nothing at
+ // the callsite if used for a `try_call`, because the
+ // unwinder ABI for `try_call`s is still "no clobbered
+ // register restores" for this ABI (so as to work with
+ // Wasmtime).
+ (isa::CallConv::PreserveAll, true) => ALL_CLOBBERS,
(isa::CallConv::SystemV, _) => DEFAULT_AAPCS_CLOBBERS,
- (isa::CallConv::Patchable, _) => NO_CLOBBERS,
+ (isa::CallConv::PreserveAll, _) => NO_CLOBBERS,
(_, false) => DEFAULT_AAPCS_CLOBBERS,
(_, true) => panic!("unimplemented clobbers for exn abi of {call_conv:?}"),
}
@@ -1184,7 +1191,9 @@ impl ABIMachineSpec for AArch64MachineDeps {
fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {
const PAYLOAD_REGS: &'static [Reg] = &[regs::xreg(0), regs::xreg(1)];
match call_conv {
- isa::CallConv::SystemV | isa::CallConv::Tail => PAYLOAD_REGS,
+ isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {
+ PAYLOAD_REGS
+ }
_ => &[],
}
}
@@ -1271,7 +1280,7 @@ fn is_reg_saved_in_prologue(
sig: &Signature,
r: RealReg,
) -> bool {
- if call_conv == isa::CallConv::Patchable {
+ if call_conv == isa::CallConv::PreserveAll {
return true;
}
diff --git a/cranelift/codegen/src/isa/aarch64/inst.isle b/cranelift/codegen/src/isa/aarch64/inst.isle
index 44c9c023f3..d48c2f63fd 100644
--- a/cranelift/codegen/src/isa/aarch64/inst.isle
+++ b/cranelift/codegen/src/isa/aarch64/inst.isle
@@ -817,9 +817,6 @@
;; An indirect return-call macro instruction.
(ReturnCallInd (info BoxReturnCallIndInfo))
- ;; A patchable call instruction.
- (PatchableCall (info BoxCallInfo))
-
;; A pseudo-instruction that captures register arguments in vregs.
(Args
(args VecArgPair))
@@ -4481,7 +4478,7 @@
;;;; Helpers for Emitting Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo) BoxCallInfo)
+(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo bool) BoxCallInfo)
(extern constructor gen_call_info gen_call_info)
(decl gen_call_ind_info (Sig Reg CallArgList CallRetList OptionTryCallInfo) BoxCallIndInfo)
@@ -4513,11 +4510,6 @@
(rule (return_call_ind_impl info)
(SideEffectNoResult.Inst (MInst.ReturnCallInd info)))
-;; Helper for creating `MInst.PatchableCall` instructions.
-(decl patchable_call_impl (BoxCallInfo) SideEffectNoResult)
-(rule (patchable_call_impl info)
- (SideEffectNoResult.Inst (MInst.PatchableCall info)))
-
;; Helpers for pinned register manipulation.
(decl write_pinned_reg (Reg) SideEffectNoResult)
diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs
index 678ffa5a1b..06e0eb0177 100644
--- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs
+++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs
@@ -2941,8 +2941,8 @@ impl MachInstEmit for Inst {
sink.put4(0xd65f0bff | (op2 << 9)); // reta{key}
}
}
- &Inst::Call { ref info } | &Inst::PatchableCall { ref info } => {
- let is_patchable = matches!(self, Inst::PatchableCall { .. });
+ &Inst::Call { ref info } => {
+ let start = sink.cur_offset();
let user_stack_map = state.take_stack_map();
sink.add_reloc(Reloc::Arm64Call, &info.dest, 0);
sink.put4(enc_jump26(0b100101, 0));
@@ -2956,8 +2956,6 @@ impl MachInstEmit for Inst {
Some(state.frame_layout.sp_to_fp()),
try_call.exception_handlers(&state.frame_layout),
);
- } else if is_patchable {
- sink.add_patchable_call_site(4);
} else {
sink.add_call_site();
}
@@ -2970,12 +2968,16 @@ impl MachInstEmit for Inst {
}
}
- // Load any stack-carried return values.
- info.emit_retval_loads::<AArch64MachineDeps, _, _>(
- state.frame_layout().stackslots_size,
- |inst| inst.emit(sink, emit_info, state),
- |needed_space| Some(Inst::EmitIsland { needed_space }),
- );
+ if info.patchable {
+ sink.add_patchable_call_site(sink.cur_offset() - start);
+ } else {
+ // Load any stack-carried return values.
+ info.emit_retval_loads::<AArch64MachineDeps, _, _>(
+ state.frame_layout().stackslots_size,
+ |inst| inst.emit(sink, emit_info, state),
+ |needed_space| Some(Inst::EmitIsland { needed_space }),
+ );
+ }
// If this is a try-call, jump to the continuation
// (normal-return) block.
diff --git a/cranelift/codegen/src/isa/aarch64/inst/mod.rs b/cranelift/codegen/src/isa/aarch64/inst/mod.rs
index 04717a5e39..cc5ff8eb3a 100644
--- a/cranelift/codegen/src/isa/aarch64/inst/mod.rs
+++ b/cranelift/codegen/src/isa/aarch64/inst/mod.rs
@@ -801,7 +801,7 @@ fn aarch64_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
}
Inst::Ret { .. } | Inst::AuthenticatedRet { .. } => {}
Inst::Jump { .. } => {}
- Inst::Call { info, .. } | Inst::PatchableCall { info, .. } => {
+ Inst::Call { info, .. } => {
let CallInfo { uses, defs, .. } = &mut **info;
for CallArgPair { vreg, preg } in uses {
collector.reg_fixed_use(vreg, *preg);
@@ -1008,7 +1008,6 @@ impl MachInst for Inst {
match self {
Inst::Call { .. }
| Inst::CallInd { .. }
- | Inst::PatchableCall { .. }
| Inst::ElfTlsGetAddr { .. }
| Inst::MachOTlsGetAddr { .. } => CallType::Regular,
@@ -1093,7 +1092,7 @@ impl MachInst for Inst {
fn is_safepoint(&self) -> bool {
match self {
- Inst::Call { .. } | Inst::CallInd { .. } | Inst::PatchableCall { .. } => true,
+ Inst::Call { .. } | Inst::CallInd { .. } => true,
_ => false,
}
}
@@ -2599,9 +2598,6 @@ impl Inst {
.unwrap_or_default();
format!("blr {rn}{try_call}")
}
- &Inst::PatchableCall { .. } => {
- format!("bl 0 ; patchable")
- }
&Inst::ReturnCall { ref info } => {
let mut s = format!(
"return_call {:?} new_stack_arg_size:{}",
diff --git a/cranelift/codegen/src/isa/aarch64/lower.isle b/cranelift/codegen/src/isa/aarch64/lower.isle
index 783c015b5a..6bb68d7b19 100644
--- a/cranelift/codegen/src/isa/aarch64/lower.isle
+++ b/cranelift/codegen/src/isa/aarch64/lower.isle
@@ -2520,7 +2520,7 @@
;;;; Rules for `func_addr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(rule (lower (func_addr (func_ref_data _ extname dist)))
+(rule (lower (func_addr (func_ref_data _ extname dist _)))
(load_ext_name (box_external_name extname) 0 dist))
;;;; Rules for `symbol_value` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2542,17 +2542,17 @@
;; Rules for `call` and `call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none) patchable))
(_ Unit (emit_side_effect (call_impl info))))
output))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (call (func_ref_data sig_ref name dist) args))
+(rule (lower (call (func_ref_data sig_ref name dist false) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
@@ -2573,30 +2573,19 @@
(_ Unit (emit_side_effect (call_ind_impl info))))
output))
-;;;; Rules for `patchable_call` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; Direct call to an in-range function.
-(rule (lower (patchable_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
- (let ((abi Sig (abi_sig sig_ref))
- (uses CallArgList (gen_call_args abi args))
- (defs CallRetList (gen_patchable_call_rets))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
- (_ Unit (emit_side_effect (patchable_call_impl info))))
- (output_none)))
-
;;;; Rules for `try_call` and `try_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near)) args et) targets)
+(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi name uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi name uses defs trycall patchable)))
(emit_side_effect (call_impl info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower_branch (try_call (func_ref_data sig_ref name dist) args et) targets)
+(rule (lower_branch (try_call (func_ref_data sig_ref name dist false) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
@@ -2625,14 +2614,14 @@
;;;; Rules for `return_call` and `return_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near) false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(info BoxReturnCallInfo (gen_return_call_info abi name uses)))
(side_effect (return_call_impl info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (return_call (func_ref_data sig_ref name dist) args))
+(rule (lower (return_call (func_ref_data sig_ref name dist false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(target Reg (load_ext_name name 0 dist))
diff --git a/cranelift/codegen/src/isa/aarch64/lower/isle.rs b/cranelift/codegen/src/isa/aarch64/lower/isle.rs
index 00d6bf2cba..b372ace5cb 100644
--- a/cranelift/codegen/src/isa/aarch64/lower/isle.rs
+++ b/cranelift/codegen/src/isa/aarch64/lower/isle.rs
@@ -83,6 +83,7 @@ impl Context for IsleContext<'_, '_, MInst, AArch64Backend> {
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> BoxCallInfo {
let stack_ret_space = self.lower_ctx.sigs()[sig].sized_stack_ret_space();
let stack_arg_space = self.lower_ctx.sigs()[sig].sized_stack_arg_space();
@@ -92,7 +93,7 @@ impl Context for IsleContext<'_, '_, MInst, AArch64Backend> {
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, patchable),
)
}
@@ -112,7 +113,7 @@ impl Context for IsleContext<'_, '_, MInst, AArch64Backend> {
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, false),
)
}
diff --git a/cranelift/codegen/src/isa/call_conv.rs b/cranelift/codegen/src/isa/call_conv.rs
index a25a16e744..a8f6ce5020 100644
--- a/cranelift/codegen/src/isa/call_conv.rs
+++ b/cranelift/codegen/src/isa/call_conv.rs
@@ -14,8 +14,6 @@ use serde_derive::{Deserialize, Serialize};
pub enum CallConv {
/// Best performance, not ABI-stable.
Fast,
- /// Smallest caller code size, not ABI-stable.
- Cold,
/// Supports tail calls, not ABI-stable except for exception
/// payload registers.
///
@@ -45,26 +43,18 @@ pub enum CallConv {
/// defines no callee-save registers, and restricts the number of return
/// registers to one integer, and one floating point.
Winch,
- /// Calling convention for patchable-call instructions.
+ /// Calling convention optimized for callsite efficiency, at the
+ /// cost of the callee. It does so by not clobbering any
+ /// registers.
///
- /// This is designed for a very specific need: we want a *single*
- /// call instruction at our callsite, with no other setup, and we
- /// don't want any registers clobbered. This allows patchable
- /// callsites to be as unobtrusive as possible.
+ /// This is designed for a very specific need: we want callsites
+ /// that we can insert as instrumentation (perhaps patchable)
+ /// while affecting surrounding instructions' register allocation
+ /// as little as possible.
///
/// The ABI is based on the native register-argument ABI on each
- /// respective platform, but puts severe restrictions on allowable
- /// signatures: only up to four arguments of integer type, and no
- /// return values. It does not support tail-calls, and disallows
- /// any extension modes on arguments.
- ///
- /// The ABI specifies that *no* registers, not even argument
- /// registers, are clobbered. This is pretty unique: it means that
- /// the call instruction will constrain regalloc to have any args
- /// in the right registers, but those registers will be preserved,
- /// so multiple patchable callsites can reuse those values. This
- /// further reduces the cost of the callsites.
- Patchable,
+ /// respective platform. It does not support tail-calls.
+ PreserveAll,
}
impl CallConv {
@@ -85,10 +75,10 @@ impl CallConv {
match flags.libcall_call_conv() {
LibcallCallConv::IsaDefault => default_call_conv,
LibcallCallConv::Fast => Self::Fast,
- LibcallCallConv::Cold => Self::Cold,
LibcallCallConv::SystemV => Self::SystemV,
LibcallCallConv::WindowsFastcall => Self::WindowsFastcall,
LibcallCallConv::AppleAarch64 => Self::AppleAarch64,
+ LibcallCallConv::PreserveAll => Self::PreserveAll,
LibcallCallConv::Probestack => Self::Probestack,
}
}
@@ -104,7 +94,7 @@ impl CallConv {
/// Does this calling convention support exceptions?
pub fn supports_exceptions(&self) -> bool {
match self {
- CallConv::Tail | CallConv::SystemV | CallConv::Winch => true,
+ CallConv::Tail | CallConv::SystemV | CallConv::Winch | CallConv::PreserveAll => true,
_ => false,
}
}
@@ -122,7 +112,7 @@ impl CallConv {
/// destinations as this return value.
pub fn exception_payload_types(&self, pointer_ty: Type) -> &[Type] {
match self {
- CallConv::Tail | CallConv::SystemV => match pointer_ty {
+ CallConv::Tail | CallConv::SystemV | CallConv::PreserveAll => match pointer_ty {
types::I32 => &[types::I32, types::I32],
types::I64 => &[types::I64, types::I64],
_ => unreachable!(),
@@ -136,14 +126,13 @@ impl fmt::Display for CallConv {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self {
Self::Fast => "fast",
- Self::Cold => "cold",
Self::Tail => "tail",
Self::SystemV => "system_v",
Self::WindowsFastcall => "windows_fastcall",
Self::AppleAarch64 => "apple_aarch64",
Self::Probestack => "probestack",
Self::Winch => "winch",
- Self::Patchable => "patchable",
+ Self::PreserveAll => "preserve_all",
})
}
}
@@ -153,14 +142,13 @@ impl str::FromStr for CallConv {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"fast" => Ok(Self::Fast),
- "cold" => Ok(Self::Cold),
"tail" => Ok(Self::Tail),
"system_v" => Ok(Self::SystemV),
"windows_fastcall" => Ok(Self::WindowsFastcall),
"apple_aarch64" => Ok(Self::AppleAarch64),
"probestack" => Ok(Self::Probestack),
"winch" => Ok(Self::Winch),
- "patchable" => Ok(Self::Patchable),
+ "preserve_all" => Ok(Self::PreserveAll),
_ => Err(()),
}
}
diff --git a/cranelift/codegen/src/isa/pulley_shared/abi.rs b/cranelift/codegen/src/isa/pulley_shared/abi.rs
index 720b5be414..3529408fb5 100644
--- a/cranelift/codegen/src/isa/pulley_shared/abi.rs
+++ b/cranelift/codegen/src/isa/pulley_shared/abi.rs
@@ -483,10 +483,10 @@ where
call_conv_of_callee: isa::CallConv,
is_exception: bool,
) -> PRegSet {
- if call_conv_of_callee == isa::CallConv::Patchable {
- NO_CLOBBERS
- } else if is_exception {
+ if is_exception {
ALL_CLOBBERS
+ } else if call_conv_of_callee == isa::CallConv::PreserveAll {
+ NO_CLOBBERS
} else {
DEFAULT_CLOBBERS
}
@@ -505,7 +505,7 @@ where
outgoing_args_size: u32,
) -> FrameLayout {
let is_callee_save = |reg: &Writable<RealReg>| match call_conv {
- isa::CallConv::Patchable => true,
+ isa::CallConv::PreserveAll => true,
_ => DEFAULT_CALLEE_SAVES.contains(reg.to_reg().into()),
};
let mut regs: Vec<Writable<RealReg>> =
diff --git a/cranelift/codegen/src/isa/pulley_shared/inst.isle b/cranelift/codegen/src/isa/pulley_shared/inst.isle
index 176346cf13..53c71b2096 100644
--- a/cranelift/codegen/src/isa/pulley_shared/inst.isle
+++ b/cranelift/codegen/src/isa/pulley_shared/inst.isle
@@ -51,9 +51,6 @@
;; An indirect call to an unknown callee.
(IndirectCall (info BoxCallIndInfo))
- ;; A patchable direct call to a known callee.
- (PatchableCall (info BoxCallInfo))
-
;; A direct return-call macro instruction.
(ReturnCall (info BoxReturnCallInfo))
@@ -722,7 +719,7 @@
;;;; Helpers for Emitting Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo) BoxCallInfo)
+(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo bool) BoxCallInfo)
(extern constructor gen_call_info gen_call_info)
(decl gen_call_ind_info (Sig Reg CallArgList CallRetList OptionTryCallInfo) BoxCallIndInfo)
@@ -752,11 +749,6 @@
(rule (indirect_call_host_impl info)
(SideEffectNoResult.Inst (MInst.IndirectCallHost info)))
-;; Helper for creating `MInst.Call` instructions.
-(decl patchable_call_impl (BoxCallInfo) SideEffectNoResult)
-(rule (patchable_call_impl info)
- (SideEffectNoResult.Inst (MInst.PatchableCall info)))
-
;; Helper for creating `MInst.ReturnCall` instructions.
(decl return_call_impl (BoxReturnCallInfo) SideEffectNoResult)
(rule (return_call_impl info)
diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs
index 70ee02ffdf..74082b4260 100644
--- a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs
+++ b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs
@@ -166,8 +166,7 @@ fn pulley_emit<P>(
sink.add_reloc_at_offset(end - size, Reloc::Abs8, &**name, *offset);
}
- Inst::Call { info } | Inst::PatchableCall { info } => {
- let is_patchable = matches!(inst, Inst::PatchableCall { .. });
+ Inst::Call { info } => {
let start = sink.cur_offset();
// If arguments happen to already be in the right register for the
@@ -199,23 +198,25 @@ fn pulley_emit<P>(
Some(state.frame_layout.sp_to_fp()),
try_call.exception_handlers(&state.frame_layout),
);
- } else if is_patchable {
- sink.add_patchable_call_site(sink.cur_offset() - start);
} else {
sink.add_call_site();
}
- let adjust = -i32::try_from(info.callee_pop_size).unwrap();
- for i in PulleyMachineDeps::<P>::gen_sp_reg_adjust(adjust) {
- i.emit(sink, emit_info, state);
- }
+ if info.patchable {
+ sink.add_patchable_call_site(sink.cur_offset() - start);
+ } else {
+ let adjust = -i32::try_from(info.callee_pop_size).unwrap();
+ for i in PulleyMachineDeps::<P>::gen_sp_reg_adjust(adjust) {
+ i.emit(sink, emit_info, state);
+ }
- // Load any stack-carried return values.
- info.emit_retval_loads::<PulleyMachineDeps<P>, _, _>(
- state.frame_layout().stackslots_size,
- |inst| inst.emit(sink, emit_info, state),
- |space_needed| Some(<InstAndKind<P>>::from(Inst::EmitIsland { space_needed })),
- );
+ // Load any stack-carried return values.
+ info.emit_retval_loads::<PulleyMachineDeps<P>, _, _>(
+ state.frame_layout().stackslots_size,
+ |inst| inst.emit(sink, emit_info, state),
+ |space_needed| Some(<InstAndKind<P>>::from(Inst::EmitIsland { space_needed })),
+ );
+ }
// If this is a try-call, jump to the continuation
// (normal-return) block.
diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs b/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs
index a75eca5ff3..9bf27e8b8a 100644
--- a/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs
+++ b/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs
@@ -150,7 +150,7 @@ fn pulley_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
collector.reg_def(dst);
}
- Inst::Call { info } | Inst::PatchableCall { info } => {
+ Inst::Call { info } => {
let CallInfo {
uses,
defs,
@@ -437,8 +437,7 @@ where
}
| Inst::Call { .. }
| Inst::IndirectCall { .. }
- | Inst::IndirectCallHost { .. }
- | Inst::PatchableCall { .. } => true,
+ | Inst::IndirectCallHost { .. } => true,
_ => false,
}
}
@@ -501,10 +500,9 @@ where
fn call_type(&self) -> CallType {
match &self.inst {
- Inst::Call { .. }
- | Inst::IndirectCall { .. }
- | Inst::IndirectCallHost { .. }
- | Inst::PatchableCall { .. } => CallType::Regular,
+ Inst::Call { .. } | Inst::IndirectCall { .. } | Inst::IndirectCallHost { .. } => {
+ CallType::Regular
+ }
Inst::ReturnCall { .. } | Inst::ReturnIndirectCall { .. } => CallType::TailCall,
@@ -726,10 +724,6 @@ impl Inst {
format!("indirect_call {callee}, {info:?}{try_call}")
}
- Inst::PatchableCall { info } => {
- format!("patchable_call {info:?}")
- }
-
Inst::ReturnCall { info } => {
format!("return_call {info:?}")
}
diff --git a/cranelift/codegen/src/isa/pulley_shared/lower.isle b/cranelift/codegen/src/isa/pulley_shared/lower.isle
index b5d9a87525..b9a9c6d020 100644
--- a/cranelift/codegen/src/isa/pulley_shared/lower.isle
+++ b/cranelift/codegen/src/isa/pulley_shared/lower.isle
@@ -141,17 +141,17 @@
;; Rules for `call` and `call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to a pulley function.
-(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none) patchable))
(_ Unit (emit_side_effect (call_impl info))))
output))
;; Direct call to a host function.
-(rule (lower (call (func_ref_data sig_ref name _) args))
+(rule (lower (call (func_ref_data sig_ref name _ false) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
@@ -171,30 +171,19 @@
(_ Unit (emit_side_effect (indirect_call_impl info))))
output))
-;;;; Rules for `patchable_call` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; Direct call to an in-range function.
-(rule (lower (patchable_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
- (let ((abi Sig (abi_sig sig_ref))
- (uses CallArgList (gen_call_args abi args))
- (defs CallRetList (gen_patchable_call_rets))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
- (_ Unit (emit_side_effect (patchable_call_impl info))))
- (output_none)))
-
;;;; Rules for `try_call` and `try_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to a pulley function.
-(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near)) args et) targets)
+(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi name uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi name uses defs trycall patchable)))
(emit_side_effect (call_impl info))))
;; Direct call to a host function.
-(rule (lower_branch (try_call (func_ref_data sig_ref name _) args et) targets)
+(rule (lower_branch (try_call (func_ref_data sig_ref name _ false) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
@@ -216,14 +205,14 @@
;;;; Rules for `return_call` and `return_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to a pulley function.
-(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near) false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(info BoxReturnCallInfo (gen_return_call_info abi name uses)))
(side_effect (return_call_impl info))))
;; Direct call to a pulley function.
-(rule (lower (return_call (func_ref_data sig_ref name dist) args))
+(rule (lower (return_call (func_ref_data sig_ref name dist false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(target Reg (load_ext_name name 0 dist))
@@ -1850,7 +1839,7 @@
;; Rules for `func_addr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(rule (lower (func_addr (func_ref_data _ extname dist)))
+(rule (lower (func_addr (func_ref_data _ extname dist _)))
(load_ext_name extname 0 dist))
diff --git a/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs b/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs
index 27fbd88216..1dd3ba587c 100644
--- a/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs
+++ b/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs
@@ -78,6 +78,7 @@ where
mut uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> BoxCallInfo {
let stack_ret_space = self.lower_ctx.sigs()[sig].sized_stack_ret_space();
let stack_arg_space = self.lower_ctx.sigs()[sig].sized_stack_arg_space();
@@ -107,7 +108,7 @@ where
let dest = PulleyCall { name, args };
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, patchable),
)
}
@@ -128,7 +129,7 @@ where
let dest = XReg::new(dest).unwrap();
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, false),
)
}
@@ -148,7 +149,7 @@ where
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, false),
)
}
diff --git a/cranelift/codegen/src/isa/riscv64/abi.rs b/cranelift/codegen/src/isa/riscv64/abi.rs
index ffde8b79b4..1292552192 100644
--- a/cranelift/codegen/src/isa/riscv64/abi.rs
+++ b/cranelift/codegen/src/isa/riscv64/abi.rs
@@ -593,6 +593,7 @@ impl ABIMachineSpec for Riscv64MachineDeps {
callee_conv: call_conv,
callee_pop_size: 0,
try_call_info: None,
+ patchable: false,
}),
});
insts
@@ -622,7 +623,13 @@ impl ABIMachineSpec for Riscv64MachineDeps {
) -> PRegSet {
match call_conv_of_callee {
isa::CallConv::Tail if is_exception => ALL_CLOBBERS,
- isa::CallConv::Patchable => NO_CLOBBERS,
+ // Note that "PreserveAll" actually preserves nothing at
+ // the callsite if used for a `try_call`, because the
+ // unwinder ABI for `try_call`s is still "no clobbered
+ // register restores" for this ABI (so as to work with
+ // Wasmtime).
+ isa::CallConv::PreserveAll if is_exception => ALL_CLOBBERS,
+ isa::CallConv::PreserveAll => NO_CLOBBERS,
_ => DEFAULT_CLOBBERS,
}
}
@@ -640,7 +647,7 @@ impl ABIMachineSpec for Riscv64MachineDeps {
outgoing_args_size: u32,
) -> FrameLayout {
let is_callee_saved = |reg: &Writable<RealReg>| match call_conv {
- isa::CallConv::Patchable => true,
+ isa::CallConv::PreserveAll => true,
_ => DEFAULT_CALLEE_SAVES.contains(reg.to_reg().into()),
};
let mut regs: Vec<Writable<RealReg>> =
@@ -720,7 +727,9 @@ impl ABIMachineSpec for Riscv64MachineDeps {
fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {
const PAYLOAD_REGS: &'static [Reg] = &[regs::a0(), regs::a1()];
match call_conv {
- isa::CallConv::SystemV | isa::CallConv::Tail => PAYLOAD_REGS,
+ isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {
+ PAYLOAD_REGS
+ }
_ => &[],
}
}
diff --git a/cranelift/codegen/src/isa/riscv64/inst.isle b/cranelift/codegen/src/isa/riscv64/inst.isle
index 9a4c29edaf..fa17ae74d9 100644
--- a/cranelift/codegen/src/isa/riscv64/inst.isle
+++ b/cranelift/codegen/src/isa/riscv64/inst.isle
@@ -117,9 +117,6 @@
;; A machine indirect-call instruction.
(CallInd (info BoxCallIndInfo))
- ;; A patchable machine direct-call instruction.
- (PatchableCall (info BoxCallInfo))
-
;; A direct return-call macro instruction.
(ReturnCall (info BoxReturnCallInfo))
@@ -3096,7 +3093,7 @@
;;;; Helpers for Emitting Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo) BoxCallInfo)
+(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo bool) BoxCallInfo)
(extern constructor gen_call_info gen_call_info)
(decl gen_call_ind_info (Sig Reg CallArgList CallRetList OptionTryCallInfo) BoxCallIndInfo)
@@ -3118,11 +3115,6 @@
(rule (call_ind_impl info)
(SideEffectNoResult.Inst (MInst.CallInd info)))
-;; Helper for creating `MInst.PatchableCall` instructions.
-(decl patchable_call_impl (BoxCallInfo) SideEffectNoResult)
-(rule (patchable_call_impl info)
- (SideEffectNoResult.Inst (MInst.PatchableCall info)))
-
;; Helper for creating `MInst.ReturnCall` instructions.
(decl return_call_impl (BoxReturnCallInfo) SideEffectNoResult)
(rule (return_call_impl info)
diff --git a/cranelift/codegen/src/isa/riscv64/inst/emit.rs b/cranelift/codegen/src/isa/riscv64/inst/emit.rs
index a4801081a9..5e631c3af1 100644
--- a/cranelift/codegen/src/isa/riscv64/inst/emit.rs
+++ b/cranelift/codegen/src/isa/riscv64/inst/emit.rs
@@ -167,7 +167,6 @@ impl Inst {
| Inst::Extend { .. }
| Inst::Call { .. }
| Inst::CallInd { .. }
- | Inst::PatchableCall { .. }
| Inst::ReturnCall { .. }
| Inst::ReturnCallInd { .. }
| Inst::Jal { .. }
@@ -1194,9 +1193,7 @@ impl Inst {
.for_each(|i| i.emit(sink, emit_info, state));
}
- &Inst::Call { ref info } | &Inst::PatchableCall { ref info } => {
- let is_patchable = matches!(self, Inst::PatchableCall { .. });
-
+ &Inst::Call { ref info } => {
sink.add_reloc(Reloc::RiscvCallPlt, &info.dest, 0);
let start = sink.cur_offset();
@@ -1214,9 +1211,6 @@ impl Inst {
Some(state.frame_layout.sp_to_fp()),
try_call.exception_handlers(&state.frame_layout),
);
- } else if is_patchable {
- let len = sink.cur_offset() - start;
- sink.add_patchable_call_site(len);
} else {
sink.add_call_site();
}
@@ -1228,12 +1222,16 @@ impl Inst {
}
}
- // Load any stack-carried return values.
- info.emit_retval_loads::<Riscv64MachineDeps, _, _>(
- state.frame_layout().stackslots_size,
- |inst| inst.emit(sink, emit_info, state),
- |needed_space| Some(Inst::EmitIsland { needed_space }),
- );
+ if info.patchable {
+ sink.add_patchable_call_site(sink.cur_offset() - start);
+ } else {
+ // Load any stack-carried return values.
+ info.emit_retval_loads::<Riscv64MachineDeps, _, _>(
+ state.frame_layout().stackslots_size,
+ |inst| inst.emit(sink, emit_info, state),
+ |needed_space| Some(Inst::EmitIsland { needed_space }),
+ );
+ }
// If this is a try-call, jump to the continuation
// (normal-return) block.
diff --git a/cranelift/codegen/src/isa/riscv64/inst/mod.rs b/cranelift/codegen/src/isa/riscv64/inst/mod.rs
index c461a86729..2521e8d358 100644
--- a/cranelift/codegen/src/isa/riscv64/inst/mod.rs
+++ b/cranelift/codegen/src/isa/riscv64/inst/mod.rs
@@ -330,7 +330,7 @@ fn riscv64_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
collector.reg_use(rn);
collector.reg_def(rd);
}
- Inst::Call { info, .. } | Inst::PatchableCall { info, .. } => {
+ Inst::Call { info, .. } => {
let CallInfo { uses, defs, .. } = &mut **info;
for CallArgPair { vreg, preg } in uses {
collector.reg_fixed_use(vreg, *preg);
@@ -725,7 +725,7 @@ impl MachInst for Inst {
fn is_safepoint(&self) -> bool {
match self {
- Inst::Call { .. } | Inst::CallInd { .. } | Inst::PatchableCall { .. } => true,
+ Inst::Call { .. } | Inst::CallInd { .. } => true,
_ => false,
}
}
@@ -764,10 +764,9 @@ impl MachInst for Inst {
fn call_type(&self) -> CallType {
match self {
- Inst::Call { .. }
- | Inst::CallInd { .. }
- | Inst::PatchableCall { .. }
- | Inst::ElfTlsGetAddr { .. } => CallType::Regular,
+ Inst::Call { .. } | Inst::CallInd { .. } | Inst::ElfTlsGetAddr { .. } => {
+ CallType::Regular
+ }
Inst::ReturnCall { .. } | Inst::ReturnCallInd { .. } => CallType::TailCall,
@@ -1357,9 +1356,6 @@ impl Inst {
.unwrap_or_default();
format!("callind {rd}{try_call}")
}
- &MInst::PatchableCall { ref info } => {
- format!("call {} ; patchable", info.dest.display(None))
- }
&MInst::ReturnCall { ref info } => {
let mut s = format!(
"return_call {:?} new_stack_arg_size:{}",
diff --git a/cranelift/codegen/src/isa/riscv64/lower.isle b/cranelift/codegen/src/isa/riscv64/lower.isle
index e1c5f02266..d1a759dcba 100644
--- a/cranelift/codegen/src/isa/riscv64/lower.isle
+++ b/cranelift/codegen/src/isa/riscv64/lower.isle
@@ -2410,7 +2410,7 @@
;;;;; Rules for `func_addr`;;;;;;;;;
(rule
- (lower (func_addr (func_ref_data _ name dist)))
+ (lower (func_addr (func_ref_data _ name dist _)))
(load_ext_name name 0 dist))
;;;;; Rules for `fcvt_to_uint`;;;;;;;;;
@@ -2700,17 +2700,17 @@
;;;; Rules for calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none) patchable))
(_ Unit (emit_side_effect (call_impl info))))
output))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (call (func_ref_data sig_ref name dist) args))
+(rule (lower (call (func_ref_data sig_ref name dist false) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
@@ -2731,28 +2731,19 @@
(_ Unit (emit_side_effect (call_ind_impl info))))
output))
-;; Patchable direct call to an in-range function.
-(rule (lower (patchable_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
- (let ((abi Sig (abi_sig sig_ref))
- (uses CallArgList (gen_call_args abi args))
- (defs CallRetList (gen_patchable_call_rets))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
- (_ Unit (emit_side_effect (patchable_call_impl info))))
- (output_none)))
-
;;;; Rules for `try_call` and `try_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near)) args et) targets)
+(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi name uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi name uses defs trycall patchable)))
(emit_side_effect (call_impl info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower_branch (try_call (func_ref_data sig_ref name dist) args et) targets)
+(rule (lower_branch (try_call (func_ref_data sig_ref name dist false) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
@@ -2775,14 +2766,14 @@
;;;; Rules for `return_call` and `return_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near) false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(info BoxReturnCallInfo (gen_return_call_info abi name uses)))
(side_effect (return_call_impl info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (return_call (func_ref_data sig_ref name dist) args))
+(rule (lower (return_call (func_ref_data sig_ref name dist false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(target Reg (load_ext_name name 0 dist))
diff --git a/cranelift/codegen/src/isa/riscv64/lower/isle.rs b/cranelift/codegen/src/isa/riscv64/lower/isle.rs
index fab00cff25..87bf480f2f 100644
--- a/cranelift/codegen/src/isa/riscv64/lower/isle.rs
+++ b/cranelift/codegen/src/isa/riscv64/lower/isle.rs
@@ -70,6 +70,7 @@ impl generated_code::Context for RV64IsleContext<'_, '_, MInst, Riscv64Backend>
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> BoxCallInfo {
let stack_ret_space = self.lower_ctx.sigs()[sig].sized_stack_ret_space();
let stack_arg_space = self.lower_ctx.sigs()[sig].sized_stack_arg_space();
@@ -79,7 +80,7 @@ impl generated_code::Context for RV64IsleContext<'_, '_, MInst, Riscv64Backend>
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, patchable),
)
}
@@ -99,7 +100,7 @@ impl generated_code::Context for RV64IsleContext<'_, '_, MInst, Riscv64Backend>
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, false),
)
}
diff --git a/cranelift/codegen/src/isa/s390x/abi.rs b/cranelift/codegen/src/isa/s390x/abi.rs
index 2cec91bbdd..7b8ad6da16 100644
--- a/cranelift/codegen/src/isa/s390x/abi.rs
+++ b/cranelift/codegen/src/isa/s390x/abi.rs
@@ -796,7 +796,7 @@ impl ABIMachineSpec for S390xMachineDeps {
// Write the dedicated clobber region.
match call_conv {
- isa::CallConv::Patchable => {
+ isa::CallConv::PreserveAll => {
// Explicitly save full v0-v31. Save r0-r5; r6-r15 are
// in the ABI-defined register save area.
//
@@ -866,7 +866,7 @@ impl ABIMachineSpec for S390xMachineDeps {
let mut insts = SmallVec::new();
match call_conv {
- isa::CallConv::Patchable => {
+ isa::CallConv::PreserveAll => {
insts.extend(gen_restore_patchable(frame_layout));
}
_ => {
@@ -923,8 +923,14 @@ impl ABIMachineSpec for S390xMachineDeps {
) -> PRegSet {
match call_conv_of_callee {
isa::CallConv::Tail if is_exception => ALL_CLOBBERS,
+ // Note that "PreserveAll" actually preserves nothing at
+ // the callsite if used for a `try_call`, because the
+ // unwinder ABI for `try_call`s is still "no clobbered
+ // register restores" for this ABI (so as to work with
+ // Wasmtime).
+ isa::CallConv::PreserveAll if is_exception => ALL_CLOBBERS,
isa::CallConv::Tail => TAIL_CLOBBERS,
- isa::CallConv::Patchable => NO_CLOBBERS,
+ isa::CallConv::PreserveAll => NO_CLOBBERS,
_ => SYSV_CLOBBERS,
}
}
@@ -991,7 +997,7 @@ impl ABIMachineSpec for S390xMachineDeps {
// and use the register-save area for r6-r15; otherwise we
// don't count GPRs and only save the FPR part of vector regs.
let mut clobber_size = match call_conv {
- isa::CallConv::Patchable => 8 * 6 + 16 * 32,
+ isa::CallConv::PreserveAll => 8 * 6 + 16 * 32,
_ => {
let mut clobber_size = 0;
for reg in &regs {
@@ -1042,7 +1048,9 @@ impl ABIMachineSpec for S390xMachineDeps {
fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {
const PAYLOAD_REGS: &'static [Reg] = &[gpr(6), gpr(7)];
match call_conv {
- isa::CallConv::SystemV | isa::CallConv::Tail => PAYLOAD_REGS,
+ isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {
+ PAYLOAD_REGS
+ }
_ => &[],
}
}
@@ -1159,7 +1167,7 @@ fn is_reg_saved_in_prologue(call_conv: isa::CallConv, r: RealReg) -> bool {
// r8 - r14 inclusive are callee-saves.
r.hw_enc() >= 8 && r.hw_enc() <= 14
}
- (isa::CallConv::Patchable, _) => true,
+ (isa::CallConv::PreserveAll, _) => true,
(_, RegClass::Int) => {
// r6 - r15 inclusive are callee-saves.
r.hw_enc() >= 6 && r.hw_enc() <= 15
diff --git a/cranelift/codegen/src/isa/s390x/inst.isle b/cranelift/codegen/src/isa/s390x/inst.isle
index 04d6839ddf..7ac2e36f83 100644
--- a/cranelift/codegen/src/isa/s390x/inst.isle
+++ b/cranelift/codegen/src/isa/s390x/inst.isle
@@ -901,11 +901,6 @@
(link WritableReg)
(info BoxCallInfo))
- ;; A patchable machine call instruction.
- (PatchableCall
- (link WritableReg)
- (info BoxCallInfo))
-
;; A machine tail call instruction (direct or indirect).
(ReturnCall
(info BoxReturnCallInfo))
@@ -2717,11 +2712,6 @@
(rule (call_impl reg info)
(SideEffectNoResult.Inst (MInst.Call reg info)))
-;; Helper for emitting `MInst.PatchableCall` instructions.
-(decl patchable_call_impl (WritableReg BoxCallInfo) SideEffectNoResult)
-(rule (patchable_call_impl reg info)
- (SideEffectNoResult.Inst (MInst.PatchableCall reg info)))
-
;; Helper for emitting `MInst.ReturnCall` instructions.
(decl return_call_impl (BoxReturnCallInfo) SideEffectNoResult)
(rule (return_call_impl info)
@@ -3432,7 +3422,7 @@
;; Helpers for generating `call` instructions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl gen_call_info (Sig CallInstDest CallArgList CallRetList OptionTryCallInfo) BoxCallInfo)
+(decl gen_call_info (Sig CallInstDest CallArgList CallRetList OptionTryCallInfo bool) BoxCallInfo)
(extern constructor gen_call_info gen_call_info)
(decl gen_return_call_info (Sig CallInstDest CallArgList) BoxReturnCallInfo)
diff --git a/cranelift/codegen/src/isa/s390x/inst/emit.rs b/cranelift/codegen/src/isa/s390x/inst/emit.rs
index 1e8ac63932..5baef0fede 100644
--- a/cranelift/codegen/src/isa/s390x/inst/emit.rs
+++ b/cranelift/codegen/src/isa/s390x/inst/emit.rs
@@ -3297,8 +3297,7 @@ impl Inst {
assert_eq!(state.nominal_sp_offset, 0);
state.nominal_sp_offset += size;
}
- &Inst::Call { link, ref info } | &Inst::PatchableCall { link, ref info } => {
- let is_patchable = matches!(self, Inst::PatchableCall { .. });
+ &Inst::Call { link, ref info } => {
let start = sink.cur_offset();
let enc: &[u8] = match &info.dest {
@@ -3324,8 +3323,6 @@ impl Inst {
Some(state.frame_layout.sp_to_fp()),
try_call.exception_handlers(&state.frame_layout),
);
- } else if is_patchable {
- sink.add_patchable_call_site(sink.cur_offset() - start);
} else {
sink.add_call_site();
}
@@ -3333,11 +3330,15 @@ impl Inst {
state.nominal_sp_offset -= info.callee_pop_size;
assert_eq!(state.nominal_sp_offset, 0);
- state.outgoing_sp_offset = info.callee_pop_size;
- for inst in S390xMachineDeps::gen_retval_loads(info) {
- inst.emit(sink, emit_info, state);
+ if info.patchable {
+ sink.add_patchable_call_site(sink.cur_offset() - start);
+ } else {
+ state.outgoing_sp_offset = info.callee_pop_size;
+ for inst in S390xMachineDeps::gen_retval_loads(info) {
+ inst.emit(sink, emit_info, state);
+ }
+ state.outgoing_sp_offset = 0;
}
- state.outgoing_sp_offset = 0;
// If this is a try-call, jump to the continuation
// (normal-return) block.
diff --git a/cranelift/codegen/src/isa/s390x/inst/mod.rs b/cranelift/codegen/src/isa/s390x/inst/mod.rs
index c82183a5bd..1e9c0aeb72 100644
--- a/cranelift/codegen/src/isa/s390x/inst/mod.rs
+++ b/cranelift/codegen/src/isa/s390x/inst/mod.rs
@@ -222,7 +222,6 @@ impl Inst {
| Inst::AllocateArgs { .. }
| Inst::Call { .. }
| Inst::ReturnCall { .. }
- | Inst::PatchableCall { .. }
| Inst::Args { .. }
| Inst::Rets { .. }
| Inst::Ret { .. }
@@ -900,7 +899,7 @@ fn s390x_get_operands(inst: &mut Inst, collector: &mut DenyReuseVisitor<impl Ope
collector.reg_use(rn);
}
Inst::AllocateArgs { .. } => {}
- Inst::Call { link, info, .. } | Inst::PatchableCall { link, info, .. } => {
+ Inst::Call { link, info, .. } => {
let CallInfo {
dest,
uses,
@@ -1126,16 +1125,14 @@ impl MachInst for Inst {
fn is_safepoint(&self) -> bool {
match self {
- Inst::Call { .. } | Inst::PatchableCall { .. } => true,
+ Inst::Call { .. } => true,
_ => false,
}
}
fn call_type(&self) -> CallType {
match self {
- Inst::Call { .. } | Inst::PatchableCall { .. } | Inst::ElfTlsGetOffset { .. } => {
- CallType::Regular
- }
+ Inst::Call { .. } | Inst::ElfTlsGetOffset { .. } => CallType::Regular,
Inst::ReturnCall { .. } => CallType::TailCall,
@@ -3195,8 +3192,7 @@ impl Inst {
format!("slgfi {}, {}", show_reg(stack_reg()), size)
}
}
- &Inst::Call { link, ref info } | &Inst::PatchableCall { link, ref info } => {
- let is_patchable = matches!(self, Inst::PatchableCall { .. });
+ &Inst::Call { link, ref info } => {
state.nominal_sp_offset = 0;
let link = link.to_reg();
let (opcode, dest) = match &info.dest {
@@ -3227,16 +3223,14 @@ impl Inst {
} else {
"".to_string()
};
- let patchable = if is_patchable { " ; patchable" } else { "" };
format!(
- "{} {}, {}{}{}{}{}",
+ "{} {}, {}{}{}{}",
opcode,
show_reg(link),
dest,
callee_pop_size,
retval_loads,
try_call,
- patchable
)
}
&Inst::ReturnCall { ref info } => {
diff --git a/cranelift/codegen/src/isa/s390x/lower.isle b/cranelift/codegen/src/isa/s390x/lower.isle
index 885634f6a1..8349fec2be 100644
--- a/cranelift/codegen/src/isa/s390x/lower.isle
+++ b/cranelift/codegen/src/isa/s390x/lower.isle
@@ -2302,11 +2302,11 @@
;;;; Rules for `func_addr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load the address of a function, target reachable via PC-relative instruction.
-(rule 1 (lower (func_addr (func_ref_data _ name (RelocDistance.Near))))
+(rule 1 (lower (func_addr (func_ref_data _ name (RelocDistance.Near) _)))
(load_addr (memarg_symbol name 0 (memflags_trusted))))
;; Load the address of a function, general case.
-(rule (lower (func_addr (func_ref_data _ name _)))
+(rule (lower (func_addr (func_ref_data _ name _ _)))
(load_symbol_reloc (SymbolReloc.Absolute name 0)))
@@ -3966,25 +3966,25 @@
;;;; Rules for `call` and `call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none) patchable))
(_ Unit (emit_side_effect (call_impl (writable_link_reg) info))))
output))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (call (func_ref_data sig_ref name _) args))
+(rule (lower (call (func_ref_data sig_ref name _ false) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_call_rets abi output))
(target Reg (load_symbol_reloc (SymbolReloc.Absolute name 0)))
- (info BoxCallInfo (gen_call_info abi target uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi target uses defs (try_call_none) false))
(_ Unit (emit_side_effect (call_impl (writable_link_reg) info))))
output))
@@ -3996,24 +3996,14 @@
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi target uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi target uses defs (try_call_none) false))
(_ Unit (emit_side_effect (call_impl (writable_link_reg) info))))
output))
-;; Patchable direct call to an in-range function.
-(rule (lower (patchable_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
- (let ((abi Sig (abi_sig sig_ref))
- (_ Unit (abi_emit_call_adjust_stack abi))
- (uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
- (defs CallRetList (gen_patchable_call_rets))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
- (_ Unit (emit_side_effect (patchable_call_impl (writable_link_reg) info))))
- (output_none)))
-
;;;; Rules for `return_call` and `return_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct tail call to an in-range function.
-(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near) false) args))
(let ((abi Sig (abi_sig sig_ref))
(_ Unit (abi_emit_return_call_adjust_stack abi))
(uses CallArgList (gen_return_call_args abi (abi_prepare_args abi args)))
@@ -4021,7 +4011,7 @@
(side_effect (return_call_impl info))))
;; Direct tail call to an out-of-range function (implicitly via pointer).
-(rule (lower (return_call (func_ref_data sig_ref name _) args))
+(rule (lower (return_call (func_ref_data sig_ref name _ false) args))
(let ((abi Sig (abi_sig sig_ref))
(_ Unit (abi_emit_return_call_adjust_stack abi))
(uses CallArgList (gen_return_call_args abi (abi_prepare_args abi args)))
@@ -4042,24 +4032,24 @@
;;;; Rules for `try_call` and `try_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near)) args et) targets)
+(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi name uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi name uses defs trycall patchable)))
(emit_side_effect (call_impl (writable_link_reg) info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower_branch (try_call (func_ref_data sig_ref name _) args et) targets)
+(rule (lower_branch (try_call (func_ref_data sig_ref name _ false) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_try_call_rets abi))
(target Reg (load_symbol_reloc (SymbolReloc.Absolute name 0)))
- (info BoxCallInfo (gen_call_info abi target uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi target uses defs trycall false)))
(emit_side_effect (call_impl (writable_link_reg) info))))
;; Indirect call.
@@ -4071,7 +4061,7 @@
(_ Unit (abi_emit_call_adjust_stack abi))
(uses CallArgList (gen_call_args abi (abi_prepare_args abi args)))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi target uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi target uses defs trycall false)))
(emit_side_effect (call_impl (writable_link_reg) info))))
diff --git a/cranelift/codegen/src/isa/s390x/lower/isle.rs b/cranelift/codegen/src/isa/s390x/lower/isle.rs
index 1660a07e97..b4bbbc7ec9 100644
--- a/cranelift/codegen/src/isa/s390x/lower/isle.rs
+++ b/cranelift/codegen/src/isa/s390x/lower/isle.rs
@@ -163,6 +163,7 @@ impl generated_code::Context for IsleContext<'_, '_, MInst, S390xBackend> {
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> BoxCallInfo {
let stack_ret_space = self.lower_ctx.sigs()[sig].sized_stack_ret_space();
let stack_arg_space = self.lower_ctx.sigs()[sig].sized_stack_arg_space();
@@ -177,7 +178,7 @@ impl generated_code::Context for IsleContext<'_, '_, MInst, S390xBackend> {
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, patchable),
)
}
diff --git a/cranelift/codegen/src/isa/x64/abi.rs b/cranelift/codegen/src/isa/x64/abi.rs
index e5b5272722..8189751064 100644
--- a/cranelift/codegen/src/isa/x64/abi.rs
+++ b/cranelift/codegen/src/isa/x64/abi.rs
@@ -855,6 +855,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
callee_conv: call_conv,
caller_conv: call_conv,
try_call_info: None,
+ patchable: false,
})));
insts
}
@@ -888,10 +889,16 @@ impl ABIMachineSpec for X64ABIMachineSpec {
) -> PRegSet {
match (call_conv_of_callee, is_exception) {
(isa::CallConv::Tail, true) => ALL_CLOBBERS,
+ // Note that "PreserveAll" actually preserves nothing at
+ // the callsite if used for a `try_call`, because the
+ // unwinder ABI for `try_call`s is still "no clobbered
+ // register restores" for this ABI (so as to work with
+ // Wasmtime).
+ (isa::CallConv::PreserveAll, true) => ALL_CLOBBERS,
(isa::CallConv::Winch, _) => ALL_CLOBBERS,
(isa::CallConv::SystemV, _) => SYSV_CLOBBERS,
(isa::CallConv::WindowsFastcall, false) => WINDOWS_CLOBBERS,
- (isa::CallConv::Patchable, _) => NO_CLOBBERS,
+ (isa::CallConv::PreserveAll, _) => NO_CLOBBERS,
(_, false) => SYSV_CLOBBERS,
(call_conv, true) => panic!("unimplemented clobbers for exn abi of {call_conv:?}"),
}
@@ -922,7 +929,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
// The `winch` calling convention doesn't have any callee-save
// registers.
CallConv::Winch => vec![],
- CallConv::Fast | CallConv::Cold | CallConv::SystemV | CallConv::Tail => regs
+ CallConv::Fast | CallConv::SystemV | CallConv::Tail => regs
.iter()
.cloned()
.filter(|r| is_callee_save_systemv(r.to_reg(), flags.enable_pinned_reg()))
@@ -932,8 +939,8 @@ impl ABIMachineSpec for X64ABIMachineSpec {
.cloned()
.filter(|r| is_callee_save_fastcall(r.to_reg(), flags.enable_pinned_reg()))
.collect(),
- // The `patchable` calling convention makes every reg a callee-save reg.
- CallConv::Patchable => regs.iter().cloned().collect(),
+ // The `preserve_all` calling convention makes every reg a callee-save reg.
+ CallConv::PreserveAll => regs.iter().cloned().collect(),
CallConv::Probestack => todo!("probestack?"),
CallConv::AppleAarch64 => unreachable!(),
};
@@ -972,7 +979,9 @@ impl ABIMachineSpec for X64ABIMachineSpec {
fn exception_payload_regs(call_conv: isa::CallConv) -> &'static [Reg] {
const PAYLOAD_REGS: &'static [Reg] = &[regs::rax(), regs::rdx()];
match call_conv {
- isa::CallConv::SystemV | isa::CallConv::Tail => PAYLOAD_REGS,
+ isa::CallConv::SystemV | isa::CallConv::Tail | isa::CallConv::PreserveAll => {
+ PAYLOAD_REGS
+ }
_ => &[],
}
}
@@ -1075,7 +1084,7 @@ fn get_intreg_for_retval(
// NB: `r15` is reserved as a scratch register.
_ => None,
},
- CallConv::Fast | CallConv::Cold | CallConv::SystemV => match intreg_idx {
+ CallConv::Fast | CallConv::SystemV | CallConv::PreserveAll => match intreg_idx {
0 => Some(regs::rax()),
1 => Some(regs::rdx()),
2 if flags.enable_llvm_abi_extensions() => Some(regs::rcx()),
@@ -1088,8 +1097,6 @@ fn get_intreg_for_retval(
},
CallConv::Winch => is_last.then(|| regs::rax()),
- // The patchable ABI does not support any return values.
- CallConv::Patchable => None,
CallConv::Probestack => todo!(),
CallConv::AppleAarch64 => unreachable!(),
}
@@ -1108,7 +1115,7 @@ fn get_fltreg_for_retval(call_conv: CallConv, fltreg_idx: usize, is_last: bool)
7 => Some(regs::xmm7()),
_ => None,
},
- CallConv::Fast | CallConv::Cold | CallConv::SystemV => match fltreg_idx {
+ CallConv::Fast | CallConv::SystemV | CallConv::PreserveAll => match fltreg_idx {
0 => Some(regs::xmm0()),
1 => Some(regs::xmm1()),
_ => None,
@@ -1118,8 +1125,6 @@ fn get_fltreg_for_retval(call_conv: CallConv, fltreg_idx: usize, is_last: bool)
_ => None,
},
CallConv::Winch => is_last.then(|| regs::xmm0()),
- // The patchable ABI does not support any return values.
- CallConv::Patchable => None,
CallConv::Probestack => todo!(),
CallConv::AppleAarch64 => unreachable!(),
}
diff --git a/cranelift/codegen/src/isa/x64/inst.isle b/cranelift/codegen/src/isa/x64/inst.isle
index b6272f43eb..d5e2f1b551 100644
--- a/cranelift/codegen/src/isa/x64/inst.isle
+++ b/cranelift/codegen/src/isa/x64/inst.isle
@@ -323,9 +323,6 @@
;; A pseudoinstruction that serves as a sequence point.
(SequencePoint)
- ;; A patchable call to a known location.
- (PatchableCallKnown (info BoxCallInfo))
-
;; An instruction assembled outside of cranelift-codegen.
(External (inst AssemblerInst))))
@@ -1313,7 +1310,7 @@
;;;; Helpers for Emitting Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo) BoxCallInfo)
+(decl gen_call_info (Sig ExternalName CallArgList CallRetList OptionTryCallInfo bool) BoxCallInfo)
(extern constructor gen_call_info gen_call_info)
(decl gen_call_ind_info (Sig RegMem CallArgList CallRetList OptionTryCallInfo) BoxCallIndInfo)
@@ -1345,11 +1342,6 @@
(rule (return_call_unknown info)
(SideEffectNoResult.Inst (MInst.ReturnCallUnknown info)))
-;; Helper for creating `PatchableCallKnown` instructions.
-(decl patchable_call_known (BoxCallInfo) SideEffectNoResult)
-(rule (patchable_call_known info)
- (SideEffectNoResult.Inst (MInst.PatchableCallKnown info)))
-
;;;; Helpers for emitting stack switches ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(decl x64_stack_switch_basic (Gpr Gpr Gpr) Gpr)
diff --git a/cranelift/codegen/src/isa/x64/inst/emit.rs b/cranelift/codegen/src/isa/x64/inst/emit.rs
index 251f4a6985..406f9961f7 100644
--- a/cranelift/codegen/src/isa/x64/inst/emit.rs
+++ b/cranelift/codegen/src/isa/x64/inst/emit.rs
@@ -408,8 +408,8 @@ pub(crate) fn emit(
Inst::addq_mi(rsp, guard_plus_count).emit(sink, info, state);
}
- Inst::CallKnown { info: call_info } | Inst::PatchableCallKnown { info: call_info } => {
- let is_patchable = matches!(inst, Inst::PatchableCallKnown { .. });
+ Inst::CallKnown { info: call_info } => {
+ let start = sink.cur_offset();
let stack_map = state.take_stack_map();
asm::inst::callq_d::new(0).emit(sink, info, state);
@@ -431,10 +431,6 @@ pub(crate) fn emit(
Some(state.frame_layout().sp_to_fp()),
try_call.exception_handlers(&state.frame_layout()),
);
- } else if is_patchable {
- // Patchable call-site of length 5 bytes. The
- // MachBuffer knows how to NOP out the callsite.
- sink.add_patchable_call_site(5);
} else {
sink.add_call_site();
}
@@ -443,19 +439,22 @@ pub(crate) fn emit(
// callee, to ensure that StackAMode values are always computed from
// a consistent SP.
if call_info.callee_pop_size > 0 {
- assert!(!is_patchable);
let rsp = Writable::from_reg(regs::rsp());
let callee_pop_size = i32::try_from(call_info.callee_pop_size)
.expect("`callee_pop_size` is too large to fit in a 32-bit immediate");
Inst::subq_mi(rsp, callee_pop_size).emit(sink, info, state);
}
- // Load any stack-carried return values.
- call_info.emit_retval_loads::<X64ABIMachineSpec, _, _>(
- state.frame_layout().stackslots_size,
- |inst| inst.emit(sink, info, state),
- |_space_needed| None,
- );
+ if call_info.patchable {
+ sink.add_patchable_call_site(sink.cur_offset() - start);
+ } else {
+ // Load any stack-carried return values.
+ call_info.emit_retval_loads::<X64ABIMachineSpec, _, _>(
+ state.frame_layout().stackslots_size,
+ |inst| inst.emit(sink, info, state),
+ |_space_needed| None,
+ );
+ }
// If this is a try-call, jump to the continuation
// (normal-return) block.
diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs
index 0cb6c7494d..298dc938b2 100644
--- a/cranelift/codegen/src/isa/x64/inst/mod.rs
+++ b/cranelift/codegen/src/isa/x64/inst/mod.rs
@@ -79,7 +79,6 @@ impl Inst {
| Inst::CallUnknown { .. }
| Inst::ReturnCallKnown { .. }
| Inst::ReturnCallUnknown { .. }
- | Inst::PatchableCallKnown { .. }
| Inst::CheckedSRemSeq { .. }
| Inst::CheckedSRemSeq8 { .. }
| Inst::CvtFloatToSintSeq { .. }
@@ -647,11 +646,6 @@ impl PrettyPrint for Inst {
s
}
- Inst::PatchableCallKnown { info } => {
- let op = ljustify("patchable_call".to_string());
- format!("{op} {:?}", info.dest)
- }
-
Inst::Rets { rets } => {
let mut s = "rets".to_string();
for ret in rets {
@@ -967,7 +961,7 @@ fn x64_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
collector.reg_early_def(tmp);
}
- Inst::CallKnown { info } | Inst::PatchableCallKnown { info } => {
+ Inst::CallKnown { info } => {
// Probestack is special and is only inserted after
// regalloc, so we do not need to represent its ABI to the
// register allocator. Assert that we don't alter that
@@ -1310,7 +1304,6 @@ impl MachInst for Inst {
match self {
Inst::CallKnown { .. }
| Inst::CallUnknown { .. }
- | Inst::PatchableCallKnown { .. }
| Inst::ElfTlsGetAddr { .. }
| Inst::MachOTlsGetAddr { .. } => CallType::Regular,
@@ -1465,9 +1458,7 @@ impl MachInst for Inst {
fn is_safepoint(&self) -> bool {
match self {
- Inst::CallKnown { .. } | Inst::CallUnknown { .. } | Inst::PatchableCallKnown { .. } => {
- true
- }
+ Inst::CallKnown { .. } | Inst::CallUnknown { .. } => true,
_ => false,
}
}
diff --git a/cranelift/codegen/src/isa/x64/lower.isle b/cranelift/codegen/src/isa/x64/lower.isle
index 018a6fa272..e8922537bd 100644
--- a/cranelift/codegen/src/isa/x64/lower.isle
+++ b/cranelift/codegen/src/isa/x64/lower.isle
@@ -3375,7 +3375,7 @@
;; Rules for `func_addr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(rule (lower (func_addr (func_ref_data _ extname dist)))
+(rule (lower (func_addr (func_ref_data _ extname dist _)))
(load_ext_name extname 0 dist))
;; Rules for `symbol_value` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3480,17 +3480,17 @@
;; Rules for `call` and `call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_call_rets abi output))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
+ (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none) patchable))
(_ Unit (emit_side_effect (call_known info))))
output))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (call (func_ref_data sig_ref name dist) args))
+(rule (lower (call (func_ref_data sig_ref name dist false) args))
(let ((output ValueRegsVec (gen_call_output sig_ref))
(abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_call_args abi args))
@@ -3514,14 +3514,14 @@
;;;; Rules for `return_call` and `return_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
+(rule 1 (lower (return_call (func_ref_data sig_ref name (RelocDistance.Near) false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(info BoxReturnCallInfo (gen_return_call_info abi name uses)))
(side_effect (return_call_known info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower (return_call (func_ref_data sig_ref name dist) args))
+(rule (lower (return_call (func_ref_data sig_ref name dist false) args))
(let ((abi Sig (abi_sig sig_ref))
(uses CallArgList (gen_return_call_args abi args))
(target Reg (load_ext_name name 0 dist))
@@ -3539,16 +3539,16 @@
;;;; Rules for `try_call` and `try_call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direct call to an in-range function.
-(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near)) args et) targets)
+(rule 1 (lower_branch (try_call (func_ref_data sig_ref name (RelocDistance.Near) patchable) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
(defs CallRetList (gen_try_call_rets abi))
- (info BoxCallInfo (gen_call_info abi name uses defs trycall)))
+ (info BoxCallInfo (gen_call_info abi name uses defs trycall patchable)))
(emit_side_effect (call_known info))))
;; Direct call to an out-of-range function (implicitly via pointer).
-(rule (lower_branch (try_call (func_ref_data sig_ref name dist) args et) targets)
+(rule (lower_branch (try_call (func_ref_data sig_ref name dist false) args et) targets)
(let ((abi Sig (abi_sig sig_ref))
(trycall OptionTryCallInfo (try_call_info et targets))
(uses CallArgList (gen_call_args abi args))
@@ -3568,17 +3568,6 @@
(info BoxCallIndInfo (gen_call_ind_info abi target uses defs trycall)))
(emit_side_effect (call_unknown info))))
-;; Rules for `patchable_call` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; Direct call to an in-range function.
-(rule (lower (patchable_call (func_ref_data sig_ref name (RelocDistance.Near)) args))
- (let ((abi Sig (abi_sig sig_ref))
- (uses CallArgList (gen_call_args abi args))
- (defs CallRetList (gen_patchable_call_rets))
- (info BoxCallInfo (gen_call_info abi name uses defs (try_call_none)))
- (_ Unit (emit_side_effect (patchable_call_known info))))
- (output_none)))
-
;; Rules for `stack_switch` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; currently, only the Basic model is supported
diff --git a/cranelift/codegen/src/isa/x64/lower.rs b/cranelift/codegen/src/isa/x64/lower.rs
index 64fc4cb902..522a155ff1 100644
--- a/cranelift/codegen/src/isa/x64/lower.rs
+++ b/cranelift/codegen/src/isa/x64/lower.rs
@@ -190,7 +190,7 @@ fn emit_vm_call(
.accumulate_outgoing_args_size(stack_ret_space + stack_arg_space);
if flags.use_colocated_libcalls() {
- let call_info = ctx.gen_call_info(sig, extname, uses, defs, None);
+ let call_info = ctx.gen_call_info(sig, extname, uses, defs, None, false);
ctx.emit(Inst::call_known(Box::new(call_info)));
} else {
let tmp = ctx.alloc_tmp(types::I64).only_reg().unwrap();
@@ -200,7 +200,7 @@ fn emit_vm_call(
offset: 0,
distance: RelocDistance::Far,
});
- let call_info = ctx.gen_call_info(sig, RegMem::reg(tmp.to_reg()), uses, defs, None);
+ let call_info = ctx.gen_call_info(sig, RegMem::reg(tmp.to_reg()), uses, defs, None, false);
ctx.emit(Inst::call_unknown(Box::new(call_info)));
}
Ok(outputs)
diff --git a/cranelift/codegen/src/isa/x64/lower/isle.rs b/cranelift/codegen/src/isa/x64/lower/isle.rs
index ff28a91da4..073284605e 100644
--- a/cranelift/codegen/src/isa/x64/lower/isle.rs
+++ b/cranelift/codegen/src/isa/x64/lower/isle.rs
@@ -83,6 +83,7 @@ impl Context for IsleContext<'_, '_, MInst, X64Backend> {
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> BoxCallInfo {
let stack_ret_space = self.lower_ctx.sigs()[sig].sized_stack_ret_space();
let stack_arg_space = self.lower_ctx.sigs()[sig].sized_stack_arg_space();
@@ -92,7 +93,7 @@ impl Context for IsleContext<'_, '_, MInst, X64Backend> {
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest, uses, defs, try_call_info),
+ .gen_call_info(sig, dest, uses, defs, try_call_info, patchable),
)
}
@@ -112,7 +113,7 @@ impl Context for IsleContext<'_, '_, MInst, X64Backend> {
Box::new(
self.lower_ctx
- .gen_call_info(sig, dest.clone(), uses, defs, try_call_info),
+ .gen_call_info(sig, dest.clone(), uses, defs, try_call_info, false),
)
}
diff --git a/cranelift/codegen/src/isa/x64/pcc.rs b/cranelift/codegen/src/isa/x64/pcc.rs
index 48dda69840..09b356d699 100644
--- a/cranelift/codegen/src/isa/x64/pcc.rs
+++ b/cranelift/codegen/src/isa/x64/pcc.rs
@@ -213,8 +213,6 @@ pub(crate) fn check(
Inst::SequencePoint { .. } => Ok(()),
- Inst::PatchableCallKnown { .. } => Ok(()),
-
Inst::External { .. } => Ok(()), // TODO: unsure what to do about this!
}
}
diff --git a/cranelift/codegen/src/machinst/abi.rs b/cranelift/codegen/src/machinst/abi.rs
index f8f045a303..e8949062f4 100644
--- a/cranelift/codegen/src/machinst/abi.rs
+++ b/cranelift/codegen/src/machinst/abi.rs
@@ -635,6 +635,8 @@ pub struct CallInfo<T> {
/// argument/return logic; they mostly differ in the metadata that
/// they emit, which this information feeds into.
pub try_call_info: Option<TryCallInfo>,
+ /// Whether this call is patchable.
+ pub patchable: bool,
}
/// Out-of-line information present on `try_call` instructions only:
@@ -674,6 +676,7 @@ impl<T> CallInfo<T> {
callee_conv: call_conv,
callee_pop_size: 0,
try_call_info: None,
+ patchable: false,
}
}
}
@@ -1219,11 +1222,10 @@ impl<M: ABIMachineSpec> Callee<M> {
call_conv == isa::CallConv::SystemV
|| call_conv == isa::CallConv::Tail
|| call_conv == isa::CallConv::Fast
- || call_conv == isa::CallConv::Cold
|| call_conv == isa::CallConv::WindowsFastcall
|| call_conv == isa::CallConv::AppleAarch64
|| call_conv == isa::CallConv::Winch
- || call_conv == isa::CallConv::Patchable,
+ || call_conv == isa::CallConv::PreserveAll,
"Unsupported calling convention: {call_conv:?}"
);
@@ -2085,6 +2087,8 @@ impl<M: ABIMachineSpec> Callee<M> {
/// `uses` is the `CallArgList` describing argument constraints
/// `defs` is the `CallRetList` describing return constraints
/// `try_call_info` describes exception targets for try_call instructions
+ /// `patchable` describes whether this callsite should emit metadata
+ /// for patching to enable/disable it.
///
/// The clobber list is computed here from the above data.
pub fn gen_call_info<T>(
@@ -2095,6 +2099,7 @@ impl<M: ABIMachineSpec> Callee<M> {
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> CallInfo<T> {
let caller_conv = self.call_conv;
let callee_conv = sigs[sig].call_conv;
@@ -2142,6 +2147,7 @@ impl<M: ABIMachineSpec> Callee<M> {
caller_conv,
callee_pop_size,
try_call_info,
+ patchable,
}
}
diff --git a/cranelift/codegen/src/machinst/isle.rs b/cranelift/codegen/src/machinst/isle.rs
index aba18a15c0..ee8b29ceaf 100644
--- a/cranelift/codegen/src/machinst/isle.rs
+++ b/cranelift/codegen/src/machinst/isle.rs
@@ -329,14 +329,22 @@ macro_rules! isle_lower_prelude_methods {
}
#[inline]
- fn func_ref_data(&mut self, func_ref: FuncRef) -> (SigRef, ExternalName, RelocDistance) {
+ fn func_ref_data(
+ &mut self,
+ func_ref: FuncRef,
+ ) -> (SigRef, ExternalName, RelocDistance, bool) {
let funcdata = &self.lower_ctx.dfg().ext_funcs[func_ref];
let reloc_distance = if funcdata.colocated {
RelocDistance::Near
} else {
RelocDistance::Far
};
- (funcdata.signature, funcdata.name.clone(), reloc_distance)
+ (
+ funcdata.signature,
+ funcdata.name.clone(),
+ reloc_distance,
+ funcdata.patchable,
+ )
}
#[inline]
diff --git a/cranelift/codegen/src/machinst/lower.rs b/cranelift/codegen/src/machinst/lower.rs
index 47eec0767e..e94d261860 100644
--- a/cranelift/codegen/src/machinst/lower.rs
+++ b/cranelift/codegen/src/machinst/lower.rs
@@ -710,10 +710,17 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
uses: CallArgList,
defs: CallRetList,
try_call_info: Option<TryCallInfo>,
+ patchable: bool,
) -> CallInfo<T> {
- self.vcode
- .abi()
- .gen_call_info(self.vcode.sigs(), sig, dest, uses, defs, try_call_info)
+ self.vcode.abi().gen_call_info(
+ self.vcode.sigs(),
+ sig,
+ dest,
+ uses,
+ defs,
+ try_call_info,
+ patchable,
+ )
}
/// Has this instruction been sunk to a use-site (i.e., away from its
diff --git a/cranelift/codegen/src/prelude_lower.isle b/cranelift/codegen/src/prelude_lower.isle
index 3fafa3fdc4..f1f492bddb 100644
--- a/cranelift/codegen/src/prelude_lower.isle
+++ b/cranelift/codegen/src/prelude_lower.isle
@@ -987,7 +987,7 @@
;; Accessor for `FuncRef`.
-(decl func_ref_data (SigRef ExternalName RelocDistance) FuncRef)
+(decl func_ref_data (SigRef ExternalName RelocDistance bool) FuncRef)
(extern extractor infallible func_ref_data func_ref_data)
;; Accessor for `ExceptionTable`.
diff --git a/cranelift/codegen/src/verifier/mod.rs b/cranelift/codegen/src/verifier/mod.rs
index 34f1f7385e..8406820d6a 100644
--- a/cranelift/codegen/src/verifier/mod.rs
+++ b/cranelift/codegen/src/verifier/mod.rs
@@ -67,6 +67,7 @@ use crate::dbg::DisplayList;
use crate::dominator_tree::DominatorTree;
use crate::entity::SparseSet;
use crate::flowgraph::{BlockPredecessor, ControlFlowGraph};
+use crate::ir::ExceptionTableItem;
use crate::ir::entities::AnyEntity;
use crate::ir::instructions::{CallInfo, InstructionFormat, ResolvedConstraint};
use crate::ir::{self, ArgumentExtension, BlockArg, ExceptionTable};
@@ -75,8 +76,7 @@ use crate::ir::{
JumpTable, MemFlags, MemoryTypeData, Opcode, SigRef, StackSlot, Type, Value, ValueDef,
ValueList, types,
};
-use crate::ir::{ExceptionTableItem, Signature};
-use crate::isa::{CallConv, TargetIsa};
+use crate::isa::TargetIsa;
use crate::print_errors::pretty_verifier_error;
use crate::settings::FlagsOrIsa;
use crate::timing;
@@ -594,7 +594,7 @@ impl<'a> Verifier<'a> {
} => {
self.verify_func_ref(inst, func_ref, errors)?;
self.verify_value_list(inst, args, errors)?;
- self.verify_callee_abi(inst, func_ref, opcode, errors)?;
+ self.verify_callee_patchability(inst, func_ref, opcode, errors)?;
}
CallIndirect {
sig_ref, ref args, ..
@@ -955,34 +955,40 @@ impl<'a> Verifier<'a> {
Ok(())
}
- fn verify_callee_abi(
+ fn verify_callee_patchability(
&self,
inst: Inst,
func_ref: FuncRef,
opcode: Opcode,
errors: &mut VerifierErrors,
) -> VerifierStepResult {
- let callee_sig_ref = self.func.dfg.ext_funcs[func_ref].signature;
- let callee_sig = &self.func.dfg.signatures[callee_sig_ref];
- let callee_abi = callee_sig.call_conv;
- match (opcode, callee_abi) {
- (Opcode::PatchableCall, CallConv::Patchable) => {
- if !self.func.dfg.ext_funcs[func_ref].colocated {
- errors.fatal((
- inst,
- self.context(inst),
- "patchable call to non-colocated function".to_string(),
- ))?;
- }
- }
- (Opcode::PatchableCall, _) => {
- errors.fatal((
- inst,
- self.context(inst),
- "patchable call with non-patchable-ABI callee".to_string(),
- ))?;
- }
- _ => {}
+ let ir::ExtFuncData {
+ patchable,
+ colocated,
+ signature,
+ name: _,
+ } = self.func.dfg.ext_funcs[func_ref];
+ let signature = &self.func.dfg.signatures[signature];
+ if patchable && (opcode == Opcode::ReturnCall || opcode == Opcode::ReturnCallIndirect) {
+ errors.fatal((
+ inst,
+ self.context(inst),
+ "patchable funcref cannot be used in a return_call".to_string(),
+ ))?;
+ }
+ if patchable && !colocated {
+ errors.fatal((
+ inst,
+ self.context(inst),
+ "patchable call to non-colocated function".to_string(),
+ ))?;
+ }
+ if patchable && !signature.returns.is_empty() {
+ errors.fatal((
+ inst,
+ self.context(inst),
+ "patchable call cannot occur to a function with return values".to_string(),
+ ))?;
}
Ok(())
}
@@ -2010,8 +2016,6 @@ impl<'a> Verifier<'a> {
}
}
- self.verify_signature(AnyEntity::Function, &self.func.signature, errors)?;
-
if errors.has_error() { Err(()) } else { Ok(()) }
}
@@ -2078,64 +2082,12 @@ impl<'a> Verifier<'a> {
Ok(())
}
- fn verify_signature(
- &self,
- loc: impl Into<AnyEntity>,
- data: &Signature,
- errors: &mut VerifierErrors,
- ) -> VerifierStepResult {
- if data.call_conv == CallConv::Patchable {
- if data.params.len() > 4 {
- return errors.fatal((
- loc,
- "signature with patchable ABI does not allow more than four arguments"
- .to_string(),
- ));
- }
- if data.returns.len() > 0 {
- return errors.fatal((
- loc,
- "signature with patchable ABI does not allow any returns".to_string(),
- ));
- }
- for param in &data.params {
- if param.value_type != crate::ir::types::I32
- && param.value_type != crate::ir::types::I64
- {
- return errors.fatal((
- loc,
- "signature with patchable ABI does not allow non-I32/I64 arguments"
- .to_string(),
- ));
- }
- if param.extension != ArgumentExtension::None {
- return errors.fatal((
- loc,
- "signature with patchable ABI does not allow sign/zero-extended arguments"
- .to_string(),
- ));
- }
- }
- }
- Ok(())
- }
-
- fn verify_signatures(&self, errors: &mut VerifierErrors) -> VerifierStepResult {
- // Check that "patchable" ABI signatures have no returns and
- // only up to four integer-typed args.
- for (sigref, data) in &self.func.dfg.signatures {
- self.verify_signature(sigref, data, errors)?;
- }
- Ok(())
- }
-
pub fn run(&self, errors: &mut VerifierErrors) -> VerifierStepResult {
self.verify_global_values(errors)?;
self.verify_memory_types(errors)?;
self.typecheck_entry_block_params(errors)?;
self.check_entry_not_cold(errors)?;
self.typecheck_function_signature(errors)?;
- self.verify_signatures(errors)?;
for block in self.func.layout.blocks() {
if self.func.layout.first_inst(block).is_none() {
diff --git a/cranelift/filetests/filetests/isa/aarch64/patchable-call.clif b/cranelift/filetests/filetests/isa/aarch64/patchable-call.clif
new file mode 100644
index 0000000000..fb5afc0197
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/aarch64/patchable-call.clif
@@ -0,0 +1,197 @@
+test compile precise-output
+target aarch64
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; stp fp, lr, [sp, #-16]!
+; mov fp, sp
+; block0:
+; mov x3, x0
+; mov x1, x3
+; mov x2, x3
+; bl 0
+; bl 0
+; ldp fp, lr, [sp], #16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stp x29, x30, [sp, #-0x10]!
+; mov x29, sp
+; block1: ; offset 0x8
+; mov x3, x0
+; mov x1, x3
+; mov x2, x3
+; bl #0x14 ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; bl #0x18 ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; ldp x29, x30, [sp], #0x10
+; ret
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; stp fp, lr, [sp, #-16]!
+; mov fp, sp
+; sub sp, sp, #16
+; block0:
+; str x0, [sp]
+; str x0, [sp, #8]
+; mov x7, x0
+; mov x1, x7
+; mov x2, x7
+; mov x3, x7
+; mov x4, x7
+; mov x5, x7
+; mov x6, x7
+; bl 0
+; str x7, [sp]
+; str x7, [sp, #8]
+; bl 0
+; add sp, sp, #16
+; ldp fp, lr, [sp], #16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stp x29, x30, [sp, #-0x10]!
+; mov x29, sp
+; sub sp, sp, #0x10
+; block1: ; offset 0xc
+; stur x0, [sp]
+; stur x0, [sp, #8]
+; mov x7, x0
+; mov x1, x7
+; mov x2, x7
+; mov x3, x7
+; mov x4, x7
+; mov x5, x7
+; mov x6, x7
+; bl #0x30 ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; stur x7, [sp]
+; stur x7, [sp, #8]
+; bl #0x3c ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; add sp, sp, #0x10
+; ldp x29, x30, [sp], #0x10
+; ret
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i64):
+ return v1
+}
+
+; VCode:
+; stp fp, lr, [sp, #-16]!
+; mov fp, sp
+; stp x27, x28, [sp, #-16]!
+; stp x25, x26, [sp, #-16]!
+; stp x23, x24, [sp, #-16]!
+; stp x21, x22, [sp, #-16]!
+; stp x19, x20, [sp, #-16]!
+; stp d14, d15, [sp, #-16]!
+; stp d12, d13, [sp, #-16]!
+; stp d10, d11, [sp, #-16]!
+; stp d8, d9, [sp, #-16]!
+; sub sp, sp, #16
+; block0:
+; str x0, [sp]
+; ldr x1, [sp]
+; ldr x2, [sp]
+; ldr x3, [sp]
+; bl 0; b MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; ldr x0, [sp]
+; add sp, sp, #16
+; ldp d8, d9, [sp], #16
+; ldp d10, d11, [sp], #16
+; ldp d12, d13, [sp], #16
+; ldp d14, d15, [sp], #16
+; ldp x19, x20, [sp], #16
+; ldp x21, x22, [sp], #16
+; ldp x23, x24, [sp], #16
+; ldp x25, x26, [sp], #16
+; ldp x27, x28, [sp], #16
+; ldp fp, lr, [sp], #16
+; ret
+; block2:
+; add sp, sp, #16
+; ldp d8, d9, [sp], #16
+; ldp d10, d11, [sp], #16
+; ldp d12, d13, [sp], #16
+; ldp d14, d15, [sp], #16
+; ldp x19, x20, [sp], #16
+; ldp x21, x22, [sp], #16
+; ldp x23, x24, [sp], #16
+; ldp x25, x26, [sp], #16
+; ldp x27, x28, [sp], #16
+; ldp fp, lr, [sp], #16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stp x29, x30, [sp, #-0x10]!
+; mov x29, sp
+; stp x27, x28, [sp, #-0x10]!
+; stp x25, x26, [sp, #-0x10]!
+; stp x23, x24, [sp, #-0x10]!
+; stp x21, x22, [sp, #-0x10]!
+; stp x19, x20, [sp, #-0x10]!
+; stp d14, d15, [sp, #-0x10]!
+; stp d12, d13, [sp, #-0x10]!
+; stp d10, d11, [sp, #-0x10]!
+; stp d8, d9, [sp, #-0x10]!
+; sub sp, sp, #0x10
+; block1: ; offset 0x30
+; stur x0, [sp]
+; ldur x1, [sp]
+; ldur x2, [sp]
+; ldur x3, [sp]
+; bl #0x40 ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; block2: ; offset 0x44
+; ldur x0, [sp]
+; add sp, sp, #0x10
+; ldp d8, d9, [sp], #0x10
+; ldp d10, d11, [sp], #0x10
+; ldp d12, d13, [sp], #0x10
+; ldp d14, d15, [sp], #0x10
+; ldp x19, x20, [sp], #0x10
+; ldp x21, x22, [sp], #0x10
+; ldp x23, x24, [sp], #0x10
+; ldp x25, x26, [sp], #0x10
+; ldp x27, x28, [sp], #0x10
+; ldp x29, x30, [sp], #0x10
+; ret
+; block3: ; offset 0x78
+; add sp, sp, #0x10
+; ldp d8, d9, [sp], #0x10
+; ldp d10, d11, [sp], #0x10
+; ldp d12, d13, [sp], #0x10
+; ldp d14, d15, [sp], #0x10
+; ldp x19, x20, [sp], #0x10
+; ldp x21, x22, [sp], #0x10
+; ldp x23, x24, [sp], #0x10
+; ldp x25, x26, [sp], #0x10
+; ldp x27, x28, [sp], #0x10
+; ldp x29, x30, [sp], #0x10
+; ret
+
diff --git a/cranelift/filetests/filetests/isa/aarch64/patchable-abi.clif b/cranelift/filetests/filetests/isa/aarch64/preserve-all.clif
similarity index 92%
rename from cranelift/filetests/filetests/isa/aarch64/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/aarch64/preserve-all.clif
index 7f9660801a..f361163f98 100644
--- a/cranelift/filetests/filetests/isa/aarch64/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/aarch64/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target aarch64
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -34,7 +34,7 @@ block0(v0: i64):
; ldp x29, x30, [sp], #0x10
; ret
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -163,10 +163,10 @@ block0(v0: i64):
; ldp x29, x30, [sp], #0x10
; ret
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
@@ -174,7 +174,7 @@ block0(v0: i64):
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
-; bl 0 ; patchable
+; bl 0
; ldp fp, lr, [sp], #16
; ret
;
@@ -183,7 +183,7 @@ block0(v0: i64):
; stp x29, x30, [sp, #-0x10]!
; mov x29, sp
; block1: ; offset 0x8
-; bl #8 ; reloc_external Call %f 0 ; patchable call: NOP out last 4 bytes
+; bl #8 ; reloc_external Call %f 0
; ldp x29, x30, [sp], #0x10
; ret
diff --git a/cranelift/filetests/filetests/isa/pulley32/call.clif b/cranelift/filetests/filetests/isa/pulley32/call.clif
index 7fbbc4b321..d18b20e2c0 100644
--- a/cranelift/filetests/filetests/isa/pulley32/call.clif
+++ b/cranelift/filetests/filetests/isa/pulley32/call.clif
@@ -16,7 +16,7 @@ block0:
; push_frame
; block0:
; xzero x2
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xone x0
; pop_frame
; ret
@@ -43,7 +43,7 @@ block0:
; push_frame
; block0:
; xzero x2
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xone x0
; pop_frame
; ret
@@ -75,7 +75,7 @@ block0:
; xone x4
; xconst8 x5, 2
; xconst8 x6, 3
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -103,7 +103,7 @@ block0:
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }], clobbers: PRegSet { bits: [65520, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }], clobbers: PRegSet { bits: [65520, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xadd64 x4, x0, x2
; xadd64 x3, x1, x3
; xadd64 x0, x4, x3
@@ -149,7 +149,7 @@ block0:
; xmov x11, x14
; xmov x12, x14
; xmov x13, x14
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame_restore 64, {}
; ret
;
@@ -217,7 +217,7 @@ block0:
; push_frame_save 112, {x16, x17, x18, x19, x26, x27, x28, x29}
; block0:
; x12 = load_addr OutgoingArg(0)
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }, CallRetPair { vreg: Writable { reg: p4i }, location: Reg(p4i, types::I64) }, CallRetPair { vreg: Writable { reg: p5i }, location: Reg(p5i, types::I64) }, CallRetPair { vreg: Writable { reg: p6i }, location: Reg(p6i, types::I64) }, CallRetPair { vreg: Writable { reg: p7i }, location: Reg(p7i, types::I64) }, CallRetPair { vreg: Writable { reg: p8i }, location: Reg(p8i, types::I64) }, CallRetPair { vreg: Writable { reg: p9i }, location: Reg(p9i, types::I64) }, CallRetPair { vreg: Writable { reg: p10i }, location: Reg(p10i, types::I64) }, CallRetPair { vreg: Writable { reg: p11i }, location: Reg(p11i, types::I64) }, CallRetPair { vreg: Writable { reg: p12i }, location: Reg(p12i, types::I64) }, CallRetPair { vreg: Writable { reg: p13i }, location: Reg(p13i, types::I64) }, CallRetPair { vreg: Writable { reg: p14i }, location: Reg(p14i, types::I64) }, CallRetPair { vreg: Writable { reg: p27i }, location: Stack(OutgoingArg(0), types::I64) }, CallRetPair { vreg: Writable { reg: p19i }, location: Stack(OutgoingArg(8), types::I64) }, CallRetPair { vreg: Writable { reg: p29i }, location: Stack(OutgoingArg(16), types::I64) }, CallRetPair { vreg: Writable { reg: p16i }, location: Stack(OutgoingArg(24), types::I64) }, CallRetPair { vreg: Writable { reg: p17i }, location: Stack(OutgoingArg(32), types::I64) }, CallRetPair { vreg: Writable { reg: p18i }, location: Stack(OutgoingArg(40), types::I64) }], clobbers: PRegSet { bits: [32768, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }, CallRetPair { vreg: Writable { reg: p4i }, location: Reg(p4i, types::I64) }, CallRetPair { vreg: Writable { reg: p5i }, location: Reg(p5i, types::I64) }, CallRetPair { vreg: Writable { reg: p6i }, location: Reg(p6i, types::I64) }, CallRetPair { vreg: Writable { reg: p7i }, location: Reg(p7i, types::I64) }, CallRetPair { vreg: Writable { reg: p8i }, location: Reg(p8i, types::I64) }, CallRetPair { vreg: Writable { reg: p9i }, location: Reg(p9i, types::I64) }, CallRetPair { vreg: Writable { reg: p10i }, location: Reg(p10i, types::I64) }, CallRetPair { vreg: Writable { reg: p11i }, location: Reg(p11i, types::I64) }, CallRetPair { vreg: Writable { reg: p12i }, location: Reg(p12i, types::I64) }, CallRetPair { vreg: Writable { reg: p13i }, location: Reg(p13i, types::I64) }, CallRetPair { vreg: Writable { reg: p14i }, location: Reg(p14i, types::I64) }, CallRetPair { vreg: Writable { reg: p27i }, location: Stack(OutgoingArg(0), types::I64) }, CallRetPair { vreg: Writable { reg: p19i }, location: Stack(OutgoingArg(8), types::I64) }, CallRetPair { vreg: Writable { reg: p29i }, location: Stack(OutgoingArg(16), types::I64) }, CallRetPair { vreg: Writable { reg: p16i }, location: Stack(OutgoingArg(24), types::I64) }, CallRetPair { vreg: Writable { reg: p17i }, location: Stack(OutgoingArg(32), types::I64) }, CallRetPair { vreg: Writable { reg: p18i }, location: Stack(OutgoingArg(40), types::I64) }], clobbers: PRegSet { bits: [32768, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xadd64 x26, x0, x1
; xadd64 x28, x2, x3
; xadd64 x2, x4, x5
@@ -291,7 +291,7 @@ block0(v0: i32):
; VCode:
; push_frame
; block0:
-; indirect_call x0, CallInfo { dest: XReg(p0i), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; indirect_call x0, CallInfo { dest: XReg(p0i), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/pulley32/exceptions.clif b/cranelift/filetests/filetests/isa/pulley32/exceptions.clif
index 3d701be051..a1f45a8d79 100644
--- a/cranelift/filetests/filetests/isa/pulley32/exceptions.clif
+++ b/cranelift/filetests/filetests/isa/pulley32/exceptions.clif
@@ -24,7 +24,7 @@ function %f0(i32) -> i32, f32, f64 {
; block0:
; fconst64 f1, 4607182418800017408
; fstore64 Slot(0), f1 // flags = notrap aligned
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }) }; jump MachLabel(1); catch [default: MachLabel(2)]
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: false }; jump MachLabel(1); catch [default: MachLabel(2)]
; block1:
; xone x0
; f1 = fload64 Slot(0) // flags = notrap aligned
@@ -75,7 +75,7 @@ function %f2(i32, i32) -> i32, f32, f64 {
; block0:
; fconst64 f1, 4607182418800017408
; fstore64 Slot(0), f1 // flags = notrap aligned
-; indirect_call x1, CallInfo { dest: XReg(p1i), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }) }; jump MachLabel(1); catch [default: MachLabel(2)]
+; indirect_call x1, CallInfo { dest: XReg(p1i), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: false }; jump MachLabel(1); catch [default: MachLabel(2)]
; block1:
; xone x0
; f1 = fload64 Slot(0) // flags = notrap aligned
@@ -132,7 +132,7 @@ function %f4(i32, i32) -> i32, f32, f64 {
; fconst64 f1, 4607182418800017408
; x2 = xload64 Slot(0) // flags = notrap aligned
; fstore64 Slot(16), f1 // flags = notrap aligned
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(3), exception_handlers: [Context(stack2), Tag(tag0, MachLabel(1)), Tag(tag1, MachLabel(2)), Context(stack0), Tag(tag0, MachLabel(4))] }) }; jump MachLabel(3); catch [context stack2, tag0: MachLabel(1), tag1: MachLabel(2), context stack0, tag0: MachLabel(4)]
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(3), exception_handlers: [Context(stack2), Tag(tag0, MachLabel(1)), Tag(tag1, MachLabel(2)), Context(stack0), Tag(tag0, MachLabel(4))] }), patchable: false }; jump MachLabel(3); catch [context stack2, tag0: MachLabel(1), tag1: MachLabel(2), context stack0, tag0: MachLabel(4)]
; block1:
; xmov x3, x0
; f1 = fload64 Slot(16) // flags = notrap aligned
@@ -207,7 +207,7 @@ function %f5() -> i32 {
; xstore64 Slot(0), x0 // flags = notrap aligned
; jump label1
; block1:
-; indirect_call_host CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(2), exception_handlers: [Default(MachLabel(3))] }) }; jump MachLabel(2); catch [default: MachLabel(3)]
+; indirect_call_host CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(2), exception_handlers: [Default(MachLabel(3))] }), patchable: false }; jump MachLabel(2); catch [default: MachLabel(3)]
; block2:
; x0 = xload64 Slot(0) // flags = notrap aligned
; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
diff --git a/cranelift/filetests/filetests/isa/pulley32/extend.clif b/cranelift/filetests/filetests/isa/pulley32/extend.clif
index fb1c5ea50f..cc2c6a6cbb 100644
--- a/cranelift/filetests/filetests/isa/pulley32/extend.clif
+++ b/cranelift/filetests/filetests/isa/pulley32/extend.clif
@@ -12,7 +12,7 @@ block0(v0: i8):
; push_frame
; block0:
; zext8 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -34,7 +34,7 @@ block0(v0: i16):
; push_frame
; block0:
; zext16 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -55,7 +55,7 @@ block0(v0: i32):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -75,7 +75,7 @@ block0(v0: i64):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -96,7 +96,7 @@ block0(v0: i8):
; push_frame
; block0:
; sext8 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -118,7 +118,7 @@ block0(v0: i16):
; push_frame
; block0:
; sext16 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -139,7 +139,7 @@ block0(v0: i32):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -159,7 +159,7 @@ block0(v0: i64):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/pulley32/patchable-call.clif b/cranelift/filetests/filetests/isa/pulley32/patchable-call.clif
new file mode 100644
index 0000000000..50c2a7e333
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/pulley32/patchable-call.clif
@@ -0,0 +1,108 @@
+test compile precise-output
+target pulley32
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; push_frame
+; block0:
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i), XReg(p0i), XReg(p0i), XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i), XReg(p0i), XReg(p0i), XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; pop_frame
+; ret
+;
+; Disassembled:
+; push_frame
+; call4 x0, x0, x0, x0, 0x5 // target = 0x6
+; call4 x0, x0, x0, x0, 0x5 // target = 0xf
+; pop_frame
+; ret
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; push_frame
+; block0:
+; xmov x9, x0
+; xmov x4, x9
+; xmov x5, x9
+; xmov x6, x9
+; xmov x7, x9
+; xmov x8, x9
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p9i), XReg(p9i), XReg(p9i), XReg(p9i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p9i), XReg(p9i), XReg(p9i), XReg(p9i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; pop_frame
+; ret
+;
+; Disassembled:
+; push_frame
+; xmov x9, x0
+; xmov x4, x9
+; xmov x5, x9
+; xmov x6, x9
+; xmov x7, x9
+; xmov x8, x9
+; call4 x9, x9, x9, x9, 0x5 // target = 0x18
+; call4 x9, x9, x9, x9, 0x5 // target = 0x21
+; pop_frame
+; ret
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i32):
+ v2 = uextend.i64 v1
+ return v2
+}
+
+; VCode:
+; push_frame_save 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; block0:
+; xmov x8, x0
+; xmov x10, x0
+; xmov x11, x0
+; xmov x12, x0
+; xstore64 Slot(0), x0 // flags = notrap aligned
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p8i), XReg(p12i), XReg(p11i), XReg(p10i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I32) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: true }; jump MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; x0 = xload64 Slot(0) // flags = notrap aligned
+; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; ret
+; block2:
+; zext32 x0, x0
+; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; ret
+;
+; Disassembled:
+; push_frame_save 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; xmov x8, x0
+; xmov x10, x0
+; xmov x11, x0
+; xmov x12, x0
+; xstore64le_o32 sp, 0, x0
+; call4 x8, x12, x11, x10, 0x5 // target = 0x1d
+; xload64le_o32 x0, sp, 0
+; pop_frame_restore 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; ret
+; zext32 x0, x0
+; pop_frame_restore 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; ret
+
diff --git a/cranelift/filetests/filetests/isa/pulley32/patchable-abi.clif b/cranelift/filetests/filetests/isa/pulley32/preserve-all.clif
similarity index 94%
rename from cranelift/filetests/filetests/isa/pulley32/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/pulley32/preserve-all.clif
index 4ac1a3a297..b5f75ff929 100644
--- a/cranelift/filetests/filetests/isa/pulley32/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/pulley32/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target pulley32
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -15,8 +15,8 @@ block0(v0: i64):
; xmov x3, x0
; xmov x1, x3
; xmov x2, x3
-; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
-; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
+; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
+; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -30,7 +30,7 @@ block0(v0: i64):
; pop_frame
; ret
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -120,7 +120,7 @@ block0(v0: i64):
; vstore128 sp+264, v30 // flags = notrap aligned
; vstore128 sp+256, v31 // flags = notrap aligned
; block0:
-; indirect_call_host CallInfo { dest: TestCase(%libcall), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: Patchable, callee_pop_size: 0, try_call_info: None }
+; indirect_call_host CallInfo { dest: TestCase(%libcall), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: PreserveAll, callee_pop_size: 0, try_call_info: None, patchable: false }
; x0 = xload64 sp+888 // flags = notrap aligned
; x1 = xload64 sp+880 // flags = notrap aligned
; x2 = xload64 sp+872 // flags = notrap aligned
@@ -370,17 +370,17 @@ block0(v0: i64):
; pop_frame_restore 896,
; ret
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
; VCode:
; push_frame
; block0:
-; patchable_call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/pulley64/call.clif b/cranelift/filetests/filetests/isa/pulley64/call.clif
index 63aeb672df..cd11d2a64e 100644
--- a/cranelift/filetests/filetests/isa/pulley64/call.clif
+++ b/cranelift/filetests/filetests/isa/pulley64/call.clif
@@ -16,7 +16,7 @@ block0:
; push_frame
; block0:
; xzero x2
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xone x0
; pop_frame
; ret
@@ -43,7 +43,7 @@ block0:
; push_frame
; block0:
; xzero x2
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xone x0
; pop_frame
; ret
@@ -75,7 +75,7 @@ block0:
; xone x4
; xconst8 x5, 2
; xconst8 x6, 3
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -103,7 +103,7 @@ block0:
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }], clobbers: PRegSet { bits: [65520, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }], clobbers: PRegSet { bits: [65520, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xadd64 x4, x0, x2
; xadd64 x3, x1, x3
; xadd64 x0, x4, x3
@@ -149,7 +149,7 @@ block0:
; xmov x11, x14
; xmov x12, x14
; xmov x13, x14
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame_restore 64, {}
; ret
;
@@ -217,7 +217,7 @@ block0:
; push_frame_save 112, {x16, x17, x18, x19, x26, x27, x28, x29}
; block0:
; x12 = load_addr OutgoingArg(0)
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }, CallRetPair { vreg: Writable { reg: p4i }, location: Reg(p4i, types::I64) }, CallRetPair { vreg: Writable { reg: p5i }, location: Reg(p5i, types::I64) }, CallRetPair { vreg: Writable { reg: p6i }, location: Reg(p6i, types::I64) }, CallRetPair { vreg: Writable { reg: p7i }, location: Reg(p7i, types::I64) }, CallRetPair { vreg: Writable { reg: p8i }, location: Reg(p8i, types::I64) }, CallRetPair { vreg: Writable { reg: p9i }, location: Reg(p9i, types::I64) }, CallRetPair { vreg: Writable { reg: p10i }, location: Reg(p10i, types::I64) }, CallRetPair { vreg: Writable { reg: p11i }, location: Reg(p11i, types::I64) }, CallRetPair { vreg: Writable { reg: p12i }, location: Reg(p12i, types::I64) }, CallRetPair { vreg: Writable { reg: p13i }, location: Reg(p13i, types::I64) }, CallRetPair { vreg: Writable { reg: p14i }, location: Reg(p14i, types::I64) }, CallRetPair { vreg: Writable { reg: p27i }, location: Stack(OutgoingArg(0), types::I64) }, CallRetPair { vreg: Writable { reg: p19i }, location: Stack(OutgoingArg(8), types::I64) }, CallRetPair { vreg: Writable { reg: p29i }, location: Stack(OutgoingArg(16), types::I64) }, CallRetPair { vreg: Writable { reg: p16i }, location: Stack(OutgoingArg(24), types::I64) }, CallRetPair { vreg: Writable { reg: p17i }, location: Stack(OutgoingArg(32), types::I64) }, CallRetPair { vreg: Writable { reg: p18i }, location: Stack(OutgoingArg(40), types::I64) }], clobbers: PRegSet { bits: [32768, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }, CallRetPair { vreg: Writable { reg: p2i }, location: Reg(p2i, types::I64) }, CallRetPair { vreg: Writable { reg: p3i }, location: Reg(p3i, types::I64) }, CallRetPair { vreg: Writable { reg: p4i }, location: Reg(p4i, types::I64) }, CallRetPair { vreg: Writable { reg: p5i }, location: Reg(p5i, types::I64) }, CallRetPair { vreg: Writable { reg: p6i }, location: Reg(p6i, types::I64) }, CallRetPair { vreg: Writable { reg: p7i }, location: Reg(p7i, types::I64) }, CallRetPair { vreg: Writable { reg: p8i }, location: Reg(p8i, types::I64) }, CallRetPair { vreg: Writable { reg: p9i }, location: Reg(p9i, types::I64) }, CallRetPair { vreg: Writable { reg: p10i }, location: Reg(p10i, types::I64) }, CallRetPair { vreg: Writable { reg: p11i }, location: Reg(p11i, types::I64) }, CallRetPair { vreg: Writable { reg: p12i }, location: Reg(p12i, types::I64) }, CallRetPair { vreg: Writable { reg: p13i }, location: Reg(p13i, types::I64) }, CallRetPair { vreg: Writable { reg: p14i }, location: Reg(p14i, types::I64) }, CallRetPair { vreg: Writable { reg: p27i }, location: Stack(OutgoingArg(0), types::I64) }, CallRetPair { vreg: Writable { reg: p19i }, location: Stack(OutgoingArg(8), types::I64) }, CallRetPair { vreg: Writable { reg: p29i }, location: Stack(OutgoingArg(16), types::I64) }, CallRetPair { vreg: Writable { reg: p16i }, location: Stack(OutgoingArg(24), types::I64) }, CallRetPair { vreg: Writable { reg: p17i }, location: Stack(OutgoingArg(32), types::I64) }, CallRetPair { vreg: Writable { reg: p18i }, location: Stack(OutgoingArg(40), types::I64) }], clobbers: PRegSet { bits: [32768, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xadd64 x26, x0, x1
; xadd64 x28, x2, x3
; xadd64 x2, x4, x5
@@ -291,7 +291,7 @@ block0(v0: i64):
; VCode:
; push_frame
; block0:
-; indirect_call x0, CallInfo { dest: XReg(p0i), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; indirect_call x0, CallInfo { dest: XReg(p0i), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -341,7 +341,7 @@ block0:
; xmov x11, x14
; xmov x12, x14
; xmov x13, x14
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p14i), XReg(p14i), XReg(p14i), XReg(p14i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame_restore 80, {}
; ret
;
@@ -387,7 +387,7 @@ block0(v0: i32):
; xstore64 sp+1000008, x20 // flags = notrap aligned
; block0:
; xmov x20, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I32) }], clobbers: PRegSet { bits: [65534, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; xmov x5, x20
; xadd32 x0, x5, x0
; x20 = xload64 sp+1000008 // flags = notrap aligned
diff --git a/cranelift/filetests/filetests/isa/pulley64/call_indirect_host.clif b/cranelift/filetests/filetests/isa/pulley64/call_indirect_host.clif
index 997b2d329b..21275303aa 100644
--- a/cranelift/filetests/filetests/isa/pulley64/call_indirect_host.clif
+++ b/cranelift/filetests/filetests/isa/pulley64/call_indirect_host.clif
@@ -11,7 +11,7 @@ block0:
; VCode:
; push_frame
; block0:
-; indirect_call_host CallInfo { dest: User(userextname0), uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; indirect_call_host CallInfo { dest: User(userextname0), uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/pulley64/exceptions.clif b/cranelift/filetests/filetests/isa/pulley64/exceptions.clif
index 60cb41cf13..82d072f1c2 100644
--- a/cranelift/filetests/filetests/isa/pulley64/exceptions.clif
+++ b/cranelift/filetests/filetests/isa/pulley64/exceptions.clif
@@ -25,7 +25,7 @@ function %f0(i32) -> i32, f32, f64 {
; block0:
; fconst64 f1, 4607182418800017408
; fstore64 Slot(0), f1 // flags = notrap aligned
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }) }; jump MachLabel(1); catch [default: MachLabel(2)]
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: false }; jump MachLabel(1); catch [default: MachLabel(2)]
; block1:
; xone x0
; f1 = fload64 Slot(0) // flags = notrap aligned
@@ -77,7 +77,7 @@ function %f2(i32, i64) -> i32, f32, f64 {
; block0:
; fconst64 f1, 4607182418800017408
; fstore64 Slot(0), f1 // flags = notrap aligned
-; indirect_call x1, CallInfo { dest: XReg(p1i), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }) }; jump MachLabel(1); catch [default: MachLabel(2)]
+; indirect_call x1, CallInfo { dest: XReg(p1i), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: false }; jump MachLabel(1); catch [default: MachLabel(2)]
; block1:
; xone x0
; f1 = fload64 Slot(0) // flags = notrap aligned
@@ -135,7 +135,7 @@ function %f4(i64, i32) -> i32, f32, f64 {
; xmov x0, x1
; xstore64 Slot(0), x1 // flags = notrap aligned
; fstore64 Slot(16), f1 // flags = notrap aligned
-; indirect_call_host CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(3), exception_handlers: [Context(stack1), Tag(tag0, MachLabel(1)), Tag(tag1, MachLabel(2)), Context(stack0), Tag(tag0, MachLabel(4))] }) }; jump MachLabel(3); catch [context stack1, tag0: MachLabel(1), tag1: MachLabel(2), context stack0, tag0: MachLabel(4)]
+; indirect_call_host CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0f }, location: Reg(p0f, types::F32) }, CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967294, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(3), exception_handlers: [Context(stack1), Tag(tag0, MachLabel(1)), Tag(tag1, MachLabel(2)), Context(stack0), Tag(tag0, MachLabel(4))] }), patchable: false }; jump MachLabel(3); catch [context stack1, tag0: MachLabel(1), tag1: MachLabel(2), context stack0, tag0: MachLabel(4)]
; block1:
; xmov x2, x0
; f1 = fload64 Slot(16) // flags = notrap aligned
@@ -209,7 +209,7 @@ function %f5() -> i64 {
; xstore64 Slot(0), x0 // flags = notrap aligned
; jump label1
; block1:
-; indirect_call_host CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(2), exception_handlers: [Default(MachLabel(3))] }) }; jump MachLabel(2); catch [default: MachLabel(3)]
+; indirect_call_host CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: Tail, caller_conv: Fast, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(2), exception_handlers: [Default(MachLabel(3))] }), patchable: false }; jump MachLabel(2); catch [default: MachLabel(3)]
; block2:
; x0 = xload64 Slot(0) // flags = notrap aligned
; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
diff --git a/cranelift/filetests/filetests/isa/pulley64/extend.clif b/cranelift/filetests/filetests/isa/pulley64/extend.clif
index 81464baf9d..93d690b7b5 100644
--- a/cranelift/filetests/filetests/isa/pulley64/extend.clif
+++ b/cranelift/filetests/filetests/isa/pulley64/extend.clif
@@ -12,7 +12,7 @@ block0(v0: i8):
; push_frame
; block0:
; zext8 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -34,7 +34,7 @@ block0(v0: i16):
; push_frame
; block0:
; zext16 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -56,7 +56,7 @@ block0(v0: i32):
; push_frame
; block0:
; zext32 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -77,7 +77,7 @@ block0(v0: i64):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -98,7 +98,7 @@ block0(v0: i8):
; push_frame
; block0:
; sext8 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -120,7 +120,7 @@ block0(v0: i16):
; push_frame
; block0:
; sext16 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -142,7 +142,7 @@ block0(v0: i32):
; push_frame
; block0:
; sext32 x2, x0
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -163,7 +163,7 @@ block0(v0: i64):
; VCode:
; push_frame
; block0:
-; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/pulley64/patchable-call.clif b/cranelift/filetests/filetests/isa/pulley64/patchable-call.clif
new file mode 100644
index 0000000000..b110c34165
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/pulley64/patchable-call.clif
@@ -0,0 +1,105 @@
+test compile precise-output
+target pulley64
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; push_frame
+; block0:
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i), XReg(p0i), XReg(p0i), XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i), XReg(p0i), XReg(p0i), XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; pop_frame
+; ret
+;
+; Disassembled:
+; push_frame
+; call4 x0, x0, x0, x0, 0x5 // target = 0x6
+; call4 x0, x0, x0, x0, 0x5 // target = 0xf
+; pop_frame
+; ret
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; push_frame
+; block0:
+; xmov x9, x0
+; xmov x4, x9
+; xmov x5, x9
+; xmov x6, x9
+; xmov x7, x9
+; xmov x8, x9
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p9i), XReg(p9i), XReg(p9i), XReg(p9i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p9i), XReg(p9i), XReg(p9i), XReg(p9i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: true }
+; pop_frame
+; ret
+;
+; Disassembled:
+; push_frame
+; xmov x9, x0
+; xmov x4, x9
+; xmov x5, x9
+; xmov x6, x9
+; xmov x7, x9
+; xmov x8, x9
+; call4 x9, x9, x9, x9, 0x5 // target = 0x18
+; call4 x9, x9, x9, x9, 0x5 // target = 0x21
+; pop_frame
+; ret
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i64):
+ return v1
+}
+
+; VCode:
+; push_frame_save 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; block0:
+; xmov x7, x0
+; xmov x9, x0
+; xmov x10, x0
+; xmov x11, x0
+; xstore64 Slot(0), x0 // flags = notrap aligned
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p7i), XReg(p11i), XReg(p10i), XReg(p9i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, location: Reg(p0i, types::I64) }, CallRetPair { vreg: Writable { reg: p1i }, location: Reg(p1i, types::I64) }], clobbers: PRegSet { bits: [4294967292, 4294967295, 4294967295, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: Some(TryCallInfo { continuation: MachLabel(1), exception_handlers: [Default(MachLabel(2))] }), patchable: true }; jump MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; x0 = xload64 Slot(0) // flags = notrap aligned
+; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; ret
+; block2:
+; pop_frame_restore 144, {x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0}
+; ret
+;
+; Disassembled:
+; push_frame_save 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; xmov x7, x0
+; xmov x9, x0
+; xmov x10, x0
+; xmov x11, x0
+; xstore64le_o32 sp, 0, x0
+; call4 x7, x11, x10, x9, 0x5 // target = 0x1d
+; xload64le_o32 x0, sp, 0
+; pop_frame_restore 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; ret
+; pop_frame_restore 144, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, sp, spilltmp0
+; ret
+
diff --git a/cranelift/filetests/filetests/isa/pulley64/patchable-abi.clif b/cranelift/filetests/filetests/isa/pulley64/preserve-all.clif
similarity index 94%
rename from cranelift/filetests/filetests/isa/pulley64/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/pulley64/preserve-all.clif
index b2b6e8671f..ede637fc82 100644
--- a/cranelift/filetests/filetests/isa/pulley64/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/pulley64/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target pulley64
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -15,8 +15,8 @@ block0(v0: i64):
; xmov x3, x0
; xmov x1, x3
; xmov x2, x3
-; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
-; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
+; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
+; indirect_call x3, CallInfo { dest: XReg(p3i), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
@@ -30,7 +30,7 @@ block0(v0: i64):
; pop_frame
; ret
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -120,7 +120,7 @@ block0(v0: i64):
; vstore128 sp+264, v30 // flags = notrap aligned
; vstore128 sp+256, v31 // flags = notrap aligned
; block0:
-; indirect_call_host CallInfo { dest: TestCase(%libcall), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: Patchable, callee_pop_size: 0, try_call_info: None }
+; indirect_call_host CallInfo { dest: TestCase(%libcall), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 4294967295, 4294967295, 0] }, callee_conv: SystemV, caller_conv: PreserveAll, callee_pop_size: 0, try_call_info: None, patchable: false }
; x0 = xload64 sp+888 // flags = notrap aligned
; x1 = xload64 sp+880 // flags = notrap aligned
; x2 = xload64 sp+872 // flags = notrap aligned
@@ -370,17 +370,17 @@ block0(v0: i64):
; pop_frame_restore 896,
; ret
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
; VCode:
; push_frame
; block0:
-; patchable_call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: Patchable, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None }
+; call CallInfo { dest: PulleyCall { name: TestCase(%f), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [0, 0, 0, 0] }, callee_conv: PreserveAll, caller_conv: SystemV, callee_pop_size: 0, try_call_info: None, patchable: false }
; pop_frame
; ret
;
diff --git a/cranelift/filetests/filetests/isa/riscv64/issue8866.clif b/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
index 4aece94c59..cee8c2fd19 100644
--- a/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
@@ -16,7 +16,7 @@ function u1:0() tail {
ss3 = explicit_slot 103, align = 1024
ss4 = explicit_slot 110, align = 512
ss5 = explicit_slot 126, align = 512
- sig0 = (f32, f64, f64, f32, i8 uext, i128, i8 uext, i32, i16 sext, i64, i64 sext, i128, i8 sext, i8, i64, i64 sext) -> i16 sext, i64 sext, f64, i32 sext, f64, i8 sext, i64 sext, f32 cold
+ sig0 = (f32, f64, f64, f32, i8 uext, i128, i8 uext, i32, i16 sext, i64, i64 sext, i128, i8 sext, i8, i64, i64 sext) -> i16 sext, i64 sext, f64, i32 sext, f64, i8 sext, i64 sext, f32 system_v
sig1 = () system_v
sig2 = (i128, i16 sext, i128 sext, i32 sext, i16, i64 uext, f32, i8 sext, f32, i8, i64, i64, i64, i64 uext, f64) -> f64, i8 uext, f32, i128, i64 uext, i8, i16 sext, i64 sext tail
sig3 = () -> i8 sext, f32, i128, i32, f32, i128 uext, i8, i8 uext, f64, i8 sext, f32 system_v
diff --git a/cranelift/filetests/filetests/isa/riscv64/patchable-call.clif b/cranelift/filetests/filetests/isa/riscv64/patchable-call.clif
new file mode 100644
index 0000000000..77c4b48e92
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/riscv64/patchable-call.clif
@@ -0,0 +1,314 @@
+test compile precise-output
+target riscv64
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; block0:
+; mv a3,a0
+; mv a1,a3
+; mv a2,a3
+; call %f
+; call %f
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; block1: ; offset 0x10
+; mv a3, a0
+; mv a1, a3
+; mv a2, a3
+; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
+; jalr ra ; patchable call: NOP out last 8 bytes
+; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
+; jalr ra ; patchable call: NOP out last 8 bytes
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; addi sp,sp,-16
+; block0:
+; sd a0,0(sp)
+; sd a0,8(sp)
+; mv a7,a0
+; mv a1,a7
+; mv a2,a7
+; mv a3,a7
+; mv a4,a7
+; mv a5,a7
+; mv a6,a7
+; call %f
+; sd a7,0(sp)
+; sd a7,8(sp)
+; call %f
+; addi sp,sp,16
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; addi sp, sp, -0x10
+; block1: ; offset 0x14
+; sd a0, 0(sp)
+; sd a0, 8(sp)
+; mv a7, a0
+; mv a1, a7
+; mv a2, a7
+; mv a3, a7
+; mv a4, a7
+; mv a5, a7
+; mv a6, a7
+; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
+; jalr ra ; patchable call: NOP out last 8 bytes
+; sd a7, 0(sp)
+; sd a7, 8(sp)
+; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
+; jalr ra ; patchable call: NOP out last 8 bytes
+; addi sp, sp, 0x10
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i64):
+ return v1
+}
+
+; VCode:
+; addi sp,sp,-16
+; sd ra,8(sp)
+; sd fp,0(sp)
+; mv fp,sp
+; addi sp,sp,-208
+; sd fp,200(sp)
+; sd s1,192(sp)
+; sd s2,184(sp)
+; sd s3,176(sp)
+; sd s4,168(sp)
+; sd s5,160(sp)
+; sd s6,152(sp)
+; sd s7,144(sp)
+; sd s8,136(sp)
+; sd s9,128(sp)
+; sd s10,120(sp)
+; sd s11,112(sp)
+; fsd fs0,104(sp)
+; fsd fs2,96(sp)
+; fsd fs3,88(sp)
+; fsd fs4,80(sp)
+; fsd fs5,72(sp)
+; fsd fs6,64(sp)
+; fsd fs7,56(sp)
+; fsd fs8,48(sp)
+; fsd fs9,40(sp)
+; fsd fs10,32(sp)
+; fsd fs11,24(sp)
+; block0:
+; sd a0,0(slot)
+; ld a1,0(slot)
+; ld a2,0(slot)
+; ld a3,0(slot)
+; call %f; j MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; ld a0,0(slot)
+; ld fp,200(sp)
+; ld s1,192(sp)
+; ld s2,184(sp)
+; ld s3,176(sp)
+; ld s4,168(sp)
+; ld s5,160(sp)
+; ld s6,152(sp)
+; ld s7,144(sp)
+; ld s8,136(sp)
+; ld s9,128(sp)
+; ld s10,120(sp)
+; ld s11,112(sp)
+; fld fs0,104(sp)
+; fld fs2,96(sp)
+; fld fs3,88(sp)
+; fld fs4,80(sp)
+; fld fs5,72(sp)
+; fld fs6,64(sp)
+; fld fs7,56(sp)
+; fld fs8,48(sp)
+; fld fs9,40(sp)
+; fld fs10,32(sp)
+; fld fs11,24(sp)
+; addi sp,sp,208
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+; block2:
+; ld fp,200(sp)
+; ld s1,192(sp)
+; ld s2,184(sp)
+; ld s3,176(sp)
+; ld s4,168(sp)
+; ld s5,160(sp)
+; ld s6,152(sp)
+; ld s7,144(sp)
+; ld s8,136(sp)
+; ld s9,128(sp)
+; ld s10,120(sp)
+; ld s11,112(sp)
+; fld fs0,104(sp)
+; fld fs2,96(sp)
+; fld fs3,88(sp)
+; fld fs4,80(sp)
+; fld fs5,72(sp)
+; fld fs6,64(sp)
+; fld fs7,56(sp)
+; fld fs8,48(sp)
+; fld fs9,40(sp)
+; fld fs10,32(sp)
+; fld fs11,24(sp)
+; addi sp,sp,208
+; ld ra,8(sp)
+; ld fp,0(sp)
+; addi sp,sp,16
+; ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+; addi sp, sp, -0x10
+; sd ra, 8(sp)
+; sd s0, 0(sp)
+; mv s0, sp
+; addi sp, sp, -0xd0
+; sd s0, 0xc8(sp)
+; sd s1, 0xc0(sp)
+; sd s2, 0xb8(sp)
+; sd s3, 0xb0(sp)
+; sd s4, 0xa8(sp)
+; sd s5, 0xa0(sp)
+; sd s6, 0x98(sp)
+; sd s7, 0x90(sp)
+; sd s8, 0x88(sp)
+; sd s9, 0x80(sp)
+; sd s10, 0x78(sp)
+; sd s11, 0x70(sp)
+; fsd fs0, 0x68(sp)
+; fsd fs2, 0x60(sp)
+; fsd fs3, 0x58(sp)
+; fsd fs4, 0x50(sp)
+; fsd fs5, 0x48(sp)
+; fsd fs6, 0x40(sp)
+; fsd fs7, 0x38(sp)
+; fsd fs8, 0x30(sp)
+; fsd fs9, 0x28(sp)
+; fsd fs10, 0x20(sp)
+; fsd fs11, 0x18(sp)
+; block1: ; offset 0x70
+; sd a0, 0(sp)
+; ld a1, 0(sp)
+; ld a2, 0(sp)
+; ld a3, 0(sp)
+; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
+; jalr ra ; patchable call: NOP out last 8 bytes
+; block2: ; offset 0x88
+; ld a0, 0(sp)
+; ld s0, 0xc8(sp)
+; ld s1, 0xc0(sp)
+; ld s2, 0xb8(sp)
+; ld s3, 0xb0(sp)
+; ld s4, 0xa8(sp)
+; ld s5, 0xa0(sp)
+; ld s6, 0x98(sp)
+; ld s7, 0x90(sp)
+; ld s8, 0x88(sp)
+; ld s9, 0x80(sp)
+; ld s10, 0x78(sp)
+; ld s11, 0x70(sp)
+; fld fs0, 0x68(sp)
+; fld fs2, 0x60(sp)
+; fld fs3, 0x58(sp)
+; fld fs4, 0x50(sp)
+; fld fs5, 0x48(sp)
+; fld fs6, 0x40(sp)
+; fld fs7, 0x38(sp)
+; fld fs8, 0x30(sp)
+; fld fs9, 0x28(sp)
+; fld fs10, 0x20(sp)
+; fld fs11, 0x18(sp)
+; addi sp, sp, 0xd0
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+; block3: ; offset 0xfc
+; ld s0, 0xc8(sp)
+; ld s1, 0xc0(sp)
+; ld s2, 0xb8(sp)
+; ld s3, 0xb0(sp)
+; ld s4, 0xa8(sp)
+; ld s5, 0xa0(sp)
+; ld s6, 0x98(sp)
+; ld s7, 0x90(sp)
+; ld s8, 0x88(sp)
+; ld s9, 0x80(sp)
+; ld s10, 0x78(sp)
+; ld s11, 0x70(sp)
+; fld fs0, 0x68(sp)
+; fld fs2, 0x60(sp)
+; fld fs3, 0x58(sp)
+; fld fs4, 0x50(sp)
+; fld fs5, 0x48(sp)
+; fld fs6, 0x40(sp)
+; fld fs7, 0x38(sp)
+; fld fs8, 0x30(sp)
+; fld fs9, 0x28(sp)
+; fld fs10, 0x20(sp)
+; fld fs11, 0x18(sp)
+; addi sp, sp, 0xd0
+; ld ra, 8(sp)
+; ld s0, 0(sp)
+; addi sp, sp, 0x10
+; ret
+
diff --git a/cranelift/filetests/filetests/isa/riscv64/patchable-abi.clif b/cranelift/filetests/filetests/isa/riscv64/preserve-all.clif
similarity index 97%
rename from cranelift/filetests/filetests/isa/riscv64/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/riscv64/preserve-all.clif
index 903d683833..0a2858214c 100644
--- a/cranelift/filetests/filetests/isa/riscv64/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target riscv64
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -42,7 +42,7 @@ block0(v0: i64):
; addi sp, sp, 0x10
; ret
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -424,10 +424,10 @@ block0(v0: i64):
; addi sp, sp, 0x10
; ret
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
@@ -437,7 +437,7 @@ block0(v0: i64):
; sd fp,0(sp)
; mv fp,sp
; block0:
-; call %f ; patchable
+; call %f
; ld ra,8(sp)
; ld fp,0(sp)
; addi sp,sp,16
@@ -451,7 +451,7 @@ block0(v0: i64):
; mv s0, sp
; block1: ; offset 0x10
; auipc ra, 0 ; reloc_external RiscvCallPlt %f 0
-; jalr ra ; patchable call: NOP out last 8 bytes
+; jalr ra
; ld ra, 8(sp)
; ld s0, 0(sp)
; addi sp, sp, 0x10
diff --git a/cranelift/filetests/filetests/isa/s390x/patchable-call.clif b/cranelift/filetests/filetests/isa/s390x/patchable-call.clif
new file mode 100644
index 0000000000..71675793f2
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/s390x/patchable-call.clif
@@ -0,0 +1,189 @@
+test compile precise-output
+target s390x
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; stmg %r14, %r15, 112(%r15)
+; aghi %r15, -160
+; block0:
+; lgr %r5, %r2
+; lgr %r3, %r5
+; lgr %r4, %r5
+; brasl %r14, %f
+; brasl %r14, %f
+; lmg %r14, %r15, 272(%r15)
+; br %r14
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stmg %r14, %r15, 0x70(%r15)
+; aghi %r15, -0xa0
+; block1: ; offset 0xa
+; lgr %r5, %r2
+; lgr %r3, %r5
+; lgr %r4, %r5
+; brasl %r14, 0x16 ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; brasl %r14, 0x1c ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; lmg %r14, %r15, 0x110(%r15)
+; br %r14
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; stmg %r6, %r15, 48(%r15)
+; aghi %r15, -200
+; block0:
+; stg %r2, 160(%r15)
+; stg %r2, 168(%r15)
+; stg %r2, 176(%r15)
+; stg %r2, 184(%r15)
+; stg %r2, 192(%r15)
+; lgr %r6, %r2
+; lgr %r3, %r6
+; lgr %r4, %r6
+; lgr %r5, %r6
+; brasl %r14, %f
+; stg %r6, 160(%r15)
+; stg %r6, 168(%r15)
+; stg %r6, 176(%r15)
+; stg %r6, 184(%r15)
+; stg %r6, 192(%r15)
+; brasl %r14, %f
+; lmg %r6, %r15, 248(%r15)
+; br %r14
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stmg %r6, %r15, 0x30(%r15)
+; aghi %r15, -0xc8
+; block1: ; offset 0xa
+; stg %r2, 0xa0(%r15)
+; stg %r2, 0xa8(%r15)
+; stg %r2, 0xb0(%r15)
+; stg %r2, 0xb8(%r15)
+; stg %r2, 0xc0(%r15)
+; lgr %r6, %r2
+; lgr %r3, %r6
+; lgr %r4, %r6
+; lgr %r5, %r6
+; brasl %r14, 0x38 ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; stg %r6, 0xa0(%r15)
+; stg %r6, 0xa8(%r15)
+; stg %r6, 0xb0(%r15)
+; stg %r6, 0xb8(%r15)
+; stg %r6, 0xc0(%r15)
+; brasl %r14, 0x5c ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; lmg %r6, %r15, 0xf8(%r15)
+; br %r14
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i64):
+ return v1
+}
+
+; VCode:
+; stmg %r6, %r15, 48(%r15)
+; aghi %r15, -232
+; std %f8, 168(%r15)
+; std %f9, 176(%r15)
+; std %f10, 184(%r15)
+; std %f11, 192(%r15)
+; std %f12, 200(%r15)
+; std %f13, 208(%r15)
+; std %f14, 216(%r15)
+; std %f15, 224(%r15)
+; block0:
+; stg %r2, 160(%r15)
+; lg %r3, 160(%r15)
+; lg %r4, 160(%r15)
+; lg %r5, 160(%r15)
+; brasl %r14, %f; jg MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; lg %r2, 160(%r15)
+; ld %f8, 168(%r15)
+; ld %f9, 176(%r15)
+; ld %f10, 184(%r15)
+; ld %f11, 192(%r15)
+; ld %f12, 200(%r15)
+; ld %f13, 208(%r15)
+; ld %f14, 216(%r15)
+; ld %f15, 224(%r15)
+; lmg %r6, %r15, 280(%r15)
+; br %r14
+; block2:
+; lgr %r2, %r6
+; ld %f8, 168(%r15)
+; ld %f9, 176(%r15)
+; ld %f10, 184(%r15)
+; ld %f11, 192(%r15)
+; ld %f12, 200(%r15)
+; ld %f13, 208(%r15)
+; ld %f14, 216(%r15)
+; ld %f15, 224(%r15)
+; lmg %r6, %r15, 280(%r15)
+; br %r14
+;
+; Disassembled:
+; block0: ; offset 0x0
+; stmg %r6, %r15, 0x30(%r15)
+; aghi %r15, -0xe8
+; std %f8, 0xa8(%r15)
+; std %f9, 0xb0(%r15)
+; std %f10, 0xb8(%r15)
+; std %f11, 0xc0(%r15)
+; std %f12, 0xc8(%r15)
+; std %f13, 0xd0(%r15)
+; std %f14, 0xd8(%r15)
+; std %f15, 0xe0(%r15)
+; block1: ; offset 0x2a
+; stg %r2, 0xa0(%r15)
+; lg %r3, 0xa0(%r15)
+; lg %r4, 0xa0(%r15)
+; lg %r5, 0xa0(%r15)
+; brasl %r14, 0x42 ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; block2: ; offset 0x48
+; lg %r2, 0xa0(%r15)
+; ld %f8, 0xa8(%r15)
+; ld %f9, 0xb0(%r15)
+; ld %f10, 0xb8(%r15)
+; ld %f11, 0xc0(%r15)
+; ld %f12, 0xc8(%r15)
+; ld %f13, 0xd0(%r15)
+; ld %f14, 0xd8(%r15)
+; ld %f15, 0xe0(%r15)
+; lmg %r6, %r15, 0x118(%r15)
+; br %r14
+; block3: ; offset 0x76
+; lgr %r2, %r6
+; ld %f8, 0xa8(%r15)
+; ld %f9, 0xb0(%r15)
+; ld %f10, 0xb8(%r15)
+; ld %f11, 0xc0(%r15)
+; ld %f12, 0xc8(%r15)
+; ld %f13, 0xd0(%r15)
+; ld %f14, 0xd8(%r15)
+; ld %f15, 0xe0(%r15)
+; lmg %r6, %r15, 0x118(%r15)
+; br %r14
+
diff --git a/cranelift/filetests/filetests/isa/s390x/patchable-abi.clif b/cranelift/filetests/filetests/isa/s390x/preserve-all.clif
similarity index 92%
rename from cranelift/filetests/filetests/isa/s390x/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/s390x/preserve-all.clif
index 25fb7f3949..5036cedbe7 100644
--- a/cranelift/filetests/filetests/isa/s390x/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/s390x/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target s390x
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -34,7 +34,7 @@ block0(v0: i64):
; lmg %r14, %r15, 0x110(%r15)
; br %r14
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -197,10 +197,10 @@ block0(v0: i64):
; lmg %r6, %r15, 0x300(%r15)
; br %r14
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
@@ -208,7 +208,7 @@ block0(v0: i64):
; stmg %r14, %r15, 112(%r15)
; aghi %r15, -160
; block0:
-; brasl %r14, %f ; patchable
+; brasl %r14, %f
; lmg %r14, %r15, 272(%r15)
; br %r14
;
@@ -217,7 +217,7 @@ block0(v0: i64):
; stmg %r14, %r15, 0x70(%r15)
; aghi %r15, -0xa0
; block1: ; offset 0xa
-; brasl %r14, 0xa ; reloc_external PLTRel32Dbl %f 2 ; patchable call: NOP out last 6 bytes
+; brasl %r14, 0xa ; reloc_external PLTRel32Dbl %f 2
; lmg %r14, %r15, 0x110(%r15)
; br %r14
diff --git a/cranelift/filetests/filetests/isa/x64/patchable-call.clif b/cranelift/filetests/filetests/isa/x64/patchable-call.clif
new file mode 100644
index 0000000000..8820c8023c
--- /dev/null
+++ b/cranelift/filetests/filetests/isa/x64/patchable-call.clif
@@ -0,0 +1,187 @@
+test compile precise-output
+target x86_64
+
+function %patchable_call(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; pushq %rbp
+; movq %rsp, %rbp
+; block0:
+; movq %rdi, %rcx
+; movq %rcx, %rdx
+; movq %rcx, %rsi
+; call TestCase(%f)
+; call TestCase(%f)
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+;
+; Disassembled:
+; block0: ; offset 0x0
+; pushq %rbp
+; movq %rsp, %rbp
+; block1: ; offset 0x4
+; movq %rdi, %rcx
+; movq %rcx, %rdx
+; movq %rcx, %rsi
+; callq 0x12 ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; callq 0x17 ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+
+
+function %patchable_call_stack_args(i64) system_v {
+ fn0 = colocated patchable %f(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ call fn0(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0)
+ return
+}
+
+; VCode:
+; pushq %rbp
+; movq %rsp, %rbp
+; subq $0x20, %rsp
+; block0:
+; movq %rdi, (%rsp)
+; movq %rdi, 8(%rsp)
+; movq %rdi, 0x10(%rsp)
+; movq %rdi, 0x18(%rsp)
+; movq %rdi, %r9
+; movq %r9, %rcx
+; movq %r9, %rdx
+; movq %r9, %rsi
+; movq %r9, %r8
+; call TestCase(%f)
+; movq %r9, (%rsp)
+; movq %r9, 8(%rsp)
+; movq %r9, 0x10(%rsp)
+; movq %r9, 0x18(%rsp)
+; call TestCase(%f)
+; addq $0x20, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+;
+; Disassembled:
+; block0: ; offset 0x0
+; pushq %rbp
+; movq %rsp, %rbp
+; subq $0x20, %rsp
+; block1: ; offset 0x8
+; movq %rdi, (%rsp)
+; movq %rdi, 8(%rsp)
+; movq %rdi, 0x10(%rsp)
+; movq %rdi, 0x18(%rsp)
+; movq %rdi, %r9
+; movq %r9, %rcx
+; movq %r9, %rdx
+; movq %r9, %rsi
+; movq %r9, %r8
+; callq 0x2f ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; movq %r9, (%rsp)
+; movq %r9, 8(%rsp)
+; movq %r9, 0x10(%rsp)
+; movq %r9, 0x18(%rsp)
+; callq 0x47 ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; addq $0x20, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+
+
+function %patchable_try_call(i64) -> i64 system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
+ fn0 = colocated patchable %f(i64, i64, i64, i64) preserve_all
+block0(v0: i64):
+ try_call fn0(v0, v0, v0, v0), sig0, block1(), [ default: block2(exn0) ]
+
+block1():
+ return v0
+
+block2(v1: i64):
+ return v1
+}
+
+; VCode:
+; pushq %rbp
+; movq %rsp, %rbp
+; subq $0x40, %rsp
+; movq %rbx, 0x10(%rsp)
+; movq %r12, 0x18(%rsp)
+; movq %r13, 0x20(%rsp)
+; movq %r14, 0x28(%rsp)
+; movq %r15, 0x30(%rsp)
+; block0:
+; movq %rdi, <offset:1>+(%rsp)
+; movq <offset:1>+(%rsp), %rcx
+; movq <offset:1>+(%rsp), %rdx
+; movq <offset:1>+(%rsp), %rsi
+; call TestCase(%f); jmp MachLabel(1); catch [default: MachLabel(2)]
+; block1:
+; movq <offset:1>+(%rsp), %rax
+; movq 0x10(%rsp), %rbx
+; movq 0x18(%rsp), %r12
+; movq 0x20(%rsp), %r13
+; movq 0x28(%rsp), %r14
+; movq 0x30(%rsp), %r15
+; addq $0x40, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+; block2:
+; movq 0x10(%rsp), %rbx
+; movq 0x18(%rsp), %r12
+; movq 0x20(%rsp), %r13
+; movq 0x28(%rsp), %r14
+; movq 0x30(%rsp), %r15
+; addq $0x40, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+;
+; Disassembled:
+; block0: ; offset 0x0
+; pushq %rbp
+; movq %rsp, %rbp
+; subq $0x40, %rsp
+; movq %rbx, 0x10(%rsp)
+; movq %r12, 0x18(%rsp)
+; movq %r13, 0x20(%rsp)
+; movq %r14, 0x28(%rsp)
+; movq %r15, 0x30(%rsp)
+; block1: ; offset 0x21
+; movq %rdi, (%rsp)
+; movq (%rsp), %rcx
+; movq (%rsp), %rdx
+; movq (%rsp), %rsi
+; callq 0x36 ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; block2: ; offset 0x36
+; movq (%rsp), %rax
+; movq 0x10(%rsp), %rbx
+; movq 0x18(%rsp), %r12
+; movq 0x20(%rsp), %r13
+; movq 0x28(%rsp), %r14
+; movq 0x30(%rsp), %r15
+; addq $0x40, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+; block3: ; offset 0x5c
+; movq 0x10(%rsp), %rbx
+; movq 0x18(%rsp), %r12
+; movq 0x20(%rsp), %r13
+; movq 0x28(%rsp), %r14
+; movq 0x30(%rsp), %r15
+; addq $0x40, %rsp
+; movq %rbp, %rsp
+; popq %rbp
+; retq
+
diff --git a/cranelift/filetests/filetests/isa/x64/patchable-abi.clif b/cranelift/filetests/filetests/isa/x64/preserve-all.clif
similarity index 92%
rename from cranelift/filetests/filetests/isa/x64/patchable-abi.clif
rename to cranelift/filetests/filetests/isa/x64/preserve-all.clif
index a197062b49..a38e8f046f 100644
--- a/cranelift/filetests/filetests/isa/x64/patchable-abi.clif
+++ b/cranelift/filetests/filetests/isa/x64/preserve-all.clif
@@ -1,8 +1,8 @@
test compile precise-output
target x86_64
-function %call_patchable_abi(i64) system_v {
- sig0 = (i64, i64, i64, i64) patchable
+function %call_preserve_all_abi(i64) system_v {
+ sig0 = (i64, i64, i64, i64) preserve_all
block0(v0: i64):
call_indirect sig0, v0(v0, v0, v0, v0)
call_indirect sig0, v0(v0, v0, v0, v0)
@@ -36,7 +36,7 @@ block0(v0: i64):
; popq %rbp
; retq
-function %patchable_abi_trampoline(i64) patchable {
+function %preserve_all_abi_trampoline(i64) preserve_all {
fn0 = %libcall(i64) system_v
block0(v0: i64):
call fn0(v0)
@@ -168,10 +168,10 @@ block0(v0: i64):
; popq %rbp
; retq
-function %patchable_call(i64) system_v {
- fn0 = colocated %f(i64) patchable
+function %preserve_all_call(i64) system_v {
+ fn0 = colocated %f(i64) preserve_all
block0(v0: i64):
- patchable_call fn0(v0)
+ call fn0(v0)
return
}
@@ -179,7 +179,7 @@ block0(v0: i64):
; pushq %rbp
; movq %rsp, %rbp
; block0:
-; patchable_call TestCase(%f)
+; call TestCase(%f)
; movq %rbp, %rsp
; popq %rbp
; retq
@@ -189,7 +189,7 @@ block0(v0: i64):
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
-; callq 9 ; reloc_external CallPCRel4 %f -4 ; patchable call: NOP out last 5 bytes
+; callq 9 ; reloc_external CallPCRel4 %f -4
; movq %rbp, %rsp
; popq %rbp
; retq
diff --git a/cranelift/filetests/filetests/parser/cold.clif b/cranelift/filetests/filetests/parser/cold.clif
deleted file mode 100644
index 55064fe6ae..0000000000
--- a/cranelift/filetests/filetests/parser/cold.clif
+++ /dev/null
@@ -1,12 +0,0 @@
-test cat
-
-function %cold() cold {
- sig0 = () cold
- sig1 = () -> i8 cold
-block1:
- return
-}
-
-; sameln: function %cold() cold {
-; nextln: sig0 = () cold
-; nextln: sig1 = () -> i8 cold
diff --git a/cranelift/filetests/filetests/parser/preserve_all.clif b/cranelift/filetests/filetests/parser/preserve_all.clif
new file mode 100644
index 0000000000..4f38ba1c38
--- /dev/null
+++ b/cranelift/filetests/filetests/parser/preserve_all.clif
@@ -0,0 +1,12 @@
+test cat
+
+function %cold() preserve_all {
+ sig0 = () preserve_all
+ sig1 = () -> i8 preserve_all
+block1:
+ return
+}
+
+; sameln: function %cold() preserve_all {
+; nextln: sig0 = () preserve_all
+; nextln: sig1 = () -> i8 preserve_all
diff --git a/cranelift/filetests/filetests/verifier/patchable-abi.clif b/cranelift/filetests/filetests/verifier/patchable-abi.clif
deleted file mode 100644
index f43a3dad13..0000000000
--- a/cranelift/filetests/filetests/verifier/patchable-abi.clif
+++ /dev/null
@@ -1,43 +0,0 @@
-test verifier
-
-function %patchable_abi_float(f32) patchable { ; error: signature with patchable ABI does not allow non-I32/I64 arguments
-block0(v0: f32):
- return
-}
-
-function %patchable_abi_arg_count(i32, i32, i32, i32, i32) patchable { ; error: signature with patchable ABI does not allow more than four arguments
-block0(v0: i32, v1: i32, v2: i32, v3: i32, v4: i32):
- return
-}
-
-function %patchable_abi_ret_count() -> i32 patchable { ; error: signature with patchable ABI does not allow any returns
-block0():
- v0 = iconst.i32 42
- return v0
-}
-
-function %patchable_abi_uext(i32 uext) patchable { ; error: signature with patchable ABI does not allow sign/zero-extended arguments
-block0(v0: i32):
- return
-}
-
-function %patchable_abi_sigref(i32) system_v {
- sig0 = (i32, i32, i32, i32, i32) patchable ; error: signature with patchable ABI does not allow more than four arguments
-
-block0(v0: i32):
- return
-}
-
-function %patchable_call_to_non_patchable_abi() system_v {
- fn0 = %f() system_v
-block0:
- patchable_call fn0() ; error: patchable call with non-patchable-ABI callee
- return
-}
-
-function %patchable_call_to_non_colocated_patchable_abi() system_v {
- fn0 = %f() patchable
-block0:
- patchable_call fn0() ; error: patchable call to non-colocated function
- return
-}
diff --git a/cranelift/filetests/filetests/verifier/patchable-call.clif b/cranelift/filetests/filetests/verifier/patchable-call.clif
new file mode 100644
index 0000000000..8f477d50e2
--- /dev/null
+++ b/cranelift/filetests/filetests/verifier/patchable-call.clif
@@ -0,0 +1,15 @@
+test verifier
+
+function %call_to_non_colocated_patchable_abi() system_v {
+ fn0 = patchable %f() system_v
+block0:
+ call fn0() ; error: patchable call to non-colocated function
+ return
+}
+
+function %call_to_non_colocated_patchable_abi() system_v {
+ fn0 = colocated patchable %f() -> i32 system_v
+block0:
+ v0 = call fn0() ; error: patchable call cannot occur to a function with return values
+ return
+}
diff --git a/cranelift/frontend/src/frontend.rs b/cranelift/frontend/src/frontend.rs
index d21ddcd107..d51dbbbbd2 100644
--- a/cranelift/frontend/src/frontend.rs
+++ b/cranelift/frontend/src/frontend.rs
@@ -845,6 +845,7 @@ impl<'a> FunctionBuilder<'a> {
name: ExternalName::LibCall(LibCall::Memcpy),
signature,
colocated: false,
+ patchable: false,
});
self.ins().call(libc_memcpy, &[dest, src, size]);
@@ -946,6 +947,7 @@ impl<'a> FunctionBuilder<'a> {
name: ExternalName::LibCall(LibCall::Memset),
signature,
colocated: false,
+ patchable: false,
});
let ch = self.ins().uextend(types::I32, ch);
@@ -1043,6 +1045,7 @@ impl<'a> FunctionBuilder<'a> {
name: ExternalName::LibCall(LibCall::Memmove),
signature,
colocated: false,
+ patchable: false,
});
self.ins().call(libc_memmove, &[dest, source, size]);
@@ -1078,6 +1081,7 @@ impl<'a> FunctionBuilder<'a> {
name: ExternalName::LibCall(LibCall::Memcmp),
signature,
colocated: false,
+ patchable: false,
});
let call = self.ins().call(libc_memcmp, &[left, right, size]);
@@ -1960,6 +1964,7 @@ block0:
name: ExternalName::User(name),
signature: sig0,
colocated: false,
+ patchable: false,
});
let mut builder = FunctionBuilder::new(&mut func, &mut fn_ctx);
diff --git a/cranelift/frontend/src/frontend/safepoints.rs b/cranelift/frontend/src/frontend/safepoints.rs
index 4c620205ed..d089677ee7 100644
--- a/cranelift/frontend/src/frontend/safepoints.rs
+++ b/cranelift/frontend/src/frontend/safepoints.rs
@@ -820,6 +820,7 @@ mod tests {
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Here the value `v1` is technically not live but our single-pass liveness
@@ -886,6 +887,7 @@ block0(v0: i32, v1: i32):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// At each `call` we are losing one more value as no longer live, so
@@ -978,6 +980,7 @@ block0:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Here we rely on the post-order to make sure that we never visit block
@@ -1080,6 +1083,7 @@ block3:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// We should not have a stack map entry for `v1` in block 1 because it
@@ -1169,6 +1173,7 @@ block2:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let block0 = builder.create_block();
@@ -1238,6 +1243,7 @@ block2:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Depending on which post-order traversal we take, we might consider
@@ -1325,6 +1331,7 @@ block2:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let block0 = builder.create_block();
@@ -1392,6 +1399,7 @@ block2:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Create an if/else CFG diamond that and check that various things get
@@ -1533,6 +1541,7 @@ block3(v5: i64, v6: i64):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Test that we support stack maps of heterogeneous types and properly
@@ -1618,6 +1627,7 @@ block0(v0: i8, v1: i16, v2: i32, v3: i64, v4: i128, v5: f32, v6: f64, v7: i8x16,
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let name = builder
@@ -1633,6 +1643,7 @@ block0(v0: i8, v1: i16, v2: i32, v3: i64, v4: i128, v5: f32, v6: f64, v7: i8x16,
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Create a series of needs-stack-map values that do not have
@@ -1738,6 +1749,7 @@ block0:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Use a variable, create a control flow diamond so that the variable
@@ -1896,6 +1908,7 @@ block3(v6: i32):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let block0 = builder.create_block();
@@ -1958,6 +1971,7 @@ block0(v0: i32):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Regression test found via fuzzing in
@@ -2035,6 +2049,7 @@ block0(v0: i32):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let name = builder
@@ -2048,6 +2063,7 @@ block0(v0: i32):
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Test that we support stack maps in loops and that we properly handle
@@ -2134,6 +2150,7 @@ block1:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let name = builder
@@ -2149,6 +2166,7 @@ block1:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Test an irreducible loop with multiple entry points, both block1 and
@@ -2273,6 +2291,7 @@ block4:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
let name = builder
@@ -2288,6 +2307,7 @@ block4:
name: ir::ExternalName::user(name),
signature,
colocated: true,
+ patchable: false,
});
// Test that we detect the `block1 -> block2 -> block3 -> block2 ->
@@ -2430,6 +2450,7 @@ block3:
name,
signature,
colocated: true,
+ patchable: false,
})
}
diff --git a/cranelift/fuzzgen/src/cranelift_arbitrary.rs b/cranelift/fuzzgen/src/cranelift_arbitrary.rs
index 888c2e2c20..7dca3450c1 100644
--- a/cranelift/fuzzgen/src/cranelift_arbitrary.rs
+++ b/cranelift/fuzzgen/src/cranelift_arbitrary.rs
@@ -45,7 +45,7 @@ impl<'a> CraneliftArbitrary for &mut Unstructured<'a> {
// These are implemented and should work on all backends
let mut allowed_callconvs = vec![
CallConv::Fast,
- CallConv::Cold,
+ CallConv::PreserveAll,
CallConv::SystemV,
CallConv::Tail,
];
diff --git a/cranelift/fuzzgen/src/function_generator.rs b/cranelift/fuzzgen/src/function_generator.rs
index 471faf770f..8165b5b14d 100644
--- a/cranelift/fuzzgen/src/function_generator.rs
+++ b/cranelift/fuzzgen/src/function_generator.rs
@@ -117,15 +117,8 @@ fn insert_call(
_args: &[Type],
_rets: &[Type],
) -> Result<()> {
- assert!(matches!(
- opcode,
- Opcode::Call | Opcode::CallIndirect | Opcode::PatchableCall
- ));
+ assert!(matches!(opcode, Opcode::Call | Opcode::CallIndirect));
let (sig, sig_ref, func_ref) = fgen.u.choose(&fgen.resources.func_refs)?.clone();
- if opcode == Opcode::PatchableCall && sig.call_conv != CallConv::Patchable {
- return Err(arbitrary::Error::IncorrectFormat.into());
- }
-
insert_call_to_function(fgen, builder, opcode, &sig, sig_ref, func_ref)
}
@@ -1623,6 +1616,7 @@ where
// time cranelift-jit puts all functions in their own mmap so
// they also cannot be colocated.
colocated: false,
+ patchable: false,
});
self.resources
diff --git a/cranelift/interpreter/src/step.rs b/cranelift/interpreter/src/step.rs
index d69b8db53f..8a7fad2323 100644
--- a/cranelift/interpreter/src/step.rs
+++ b/cranelift/interpreter/src/step.rs
@@ -1323,7 +1323,6 @@ where
Opcode::GetExceptionHandlerAddress => unimplemented!("GetExceptionHandlerAddress"),
Opcode::SequencePoint => unimplemented!("SequencePoint"),
- Opcode::PatchableCall => unimplemented!("PatchableCall"),
})
}
diff --git a/cranelift/module/src/module.rs b/cranelift/module/src/module.rs
index fc48ad7205..79dcc1efec 100644
--- a/cranelift/module/src/module.rs
+++ b/cranelift/module/src/module.rs
@@ -915,6 +915,7 @@ pub trait Module {
name: ir::ExternalName::user(user_name_ref),
signature,
colocated,
+ patchable: false,
})
}
diff --git a/cranelift/reader/src/parser.rs b/cranelift/reader/src/parser.rs
index e2172ae99b..99ee3ad418 100644
--- a/cranelift/reader/src/parser.rs
+++ b/cranelift/reader/src/parser.rs
@@ -384,6 +384,7 @@ impl Context {
name: ExternalName::testcase(""),
signature: SigRef::reserved_value(),
colocated: false,
+ patchable: false,
});
}
self.function.dfg.ext_funcs[fn_] = data;
@@ -1405,11 +1406,6 @@ impl<'a> Parser<'a> {
}
_ => return err!(self.loc, "unknown calling convention: {}", text),
},
-
- Some(Token::Cold) => {
- self.consume();
- sig.call_conv = CallConv::Cold;
- }
_ => {}
}
@@ -1858,7 +1854,7 @@ impl<'a> Parser<'a> {
//
// Two variants:
//
- // function-decl ::= FuncRef(fnref) "=" ["colocated"]" name function-decl-sig
+ // function-decl ::= FuncRef(fnref) "=" ["colocated"] ["patchable"] name function-decl-sig
// function-decl-sig ::= SigRef(sig) | signature
//
// The first variant allocates a new signature reference. The second references an existing
@@ -1870,16 +1866,18 @@ impl<'a> Parser<'a> {
let loc = self.loc;
- // function-decl ::= FuncRef(fnref) "=" * ["colocated"] name function-decl-sig
+ // function-decl ::= FuncRef(fnref) "=" * ["colocated"] ["patchable"] name function-decl-sig
let colocated = self.optional(Token::Identifier("colocated"));
+ // function-decl ::= FuncRef(fnref) "=" ["colocated"] * ["patchable"] name function-decl-sig
+ let patchable = self.optional(Token::Identifier("patchable"));
- // function-decl ::= FuncRef(fnref) "=" ["colocated"] * name function-decl-sig
+ // function-decl ::= FuncRef(fnref) "=" ["colocated"] ["patchable"] * name function-decl-sig
let name = self.parse_external_name()?;
- // function-decl ::= FuncRef(fnref) "=" ["colocated"] name * function-decl-sig
+ // function-decl ::= FuncRef(fnref) "=" ["colocated"] ["patchable"] name * function-decl-sig
let data = match self.token() {
Some(Token::LPar) => {
- // function-decl ::= FuncRef(fnref) "=" ["colocated"] name * signature
+ // function-decl ::= FuncRef(fnref) "=" ["colocated"] ["patchable"] name * signature
let sig = self.parse_signature()?;
let sigref = ctx.function.import_signature(sig);
ctx.map
@@ -1889,6 +1887,7 @@ impl<'a> Parser<'a> {
name,
signature: sigref,
colocated,
+ patchable,
}
}
Some(Token::SigRef(sig_src)) => {
@@ -1904,6 +1903,7 @@ impl<'a> Parser<'a> {
name,
signature: sig,
colocated,
+ patchable,
}
}
_ => return err!(self.loc, "expected 'function' or sig«n» in function decl"),
@@ -3879,10 +3879,10 @@ mod tests {
);
// However, we can specify a different calling convention to be the default.
- let mut parser = Parser::new(code).with_default_calling_convention(CallConv::Cold);
+ let mut parser = Parser::new(code).with_default_calling_convention(CallConv::PreserveAll);
assert_eq!(
parser.parse_function().unwrap().0.signature.call_conv,
- CallConv::Cold
+ CallConv::PreserveAll
);
}
diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rs
index a2d384bb0f..9cad0c0b0c 100644
--- a/crates/cranelift/src/compiler.rs
+++ b/crates/cranelift/src/compiler.rs
@@ -187,6 +187,7 @@ impl Compiler {
// This is the signal that a special `call_indirect_host`
// opcode is used to jump from pulley to the host.
colocated: false,
+ patchable: false,
});
let mut raw_args = vec![addr];
raw_args.extend_from_slice(args);
@@ -721,10 +722,10 @@ impl wasmtime_environ::Compiler for Compiler {
FuncKey::WasmToBuiltinTrampoline(builtin) => (builtin, sigs.wasm_signature(builtin)),
FuncKey::PatchableToBuiltinTrampoline(builtin) => {
let mut sig = sigs.wasm_signature(builtin);
- // Patchable-ABI functions cannot return anything. We
+ // Patchable functions cannot return anything. We
// raise any errors that occur below so this is fine.
sig.returns.clear();
- sig.call_conv = CallConv::Patchable;
+ sig.call_conv = CallConv::PreserveAll;
(builtin, sig)
}
_ => unreachable!(),
@@ -1364,6 +1365,7 @@ impl Compiler {
name,
signature,
colocated: true,
+ patchable: false,
})
};
diff --git a/crates/cranelift/src/func_environ.rs b/crates/cranelift/src/func_environ.rs
index 0ec63d7e4a..6ae2a452fe 100644
--- a/crates/cranelift/src/func_environ.rs
+++ b/crates/cranelift/src/func_environ.rs
@@ -72,6 +72,7 @@ impl BuiltinFunctions {
name,
signature,
colocated: true,
+ patchable: false,
});
*cache = Some(f);
f
@@ -79,7 +80,7 @@ impl BuiltinFunctions {
pub(crate) fn patchable_breakpoint(&mut self, func: &mut Function) -> ir::FuncRef {
*self.breakpoint_trampoline.get_or_insert_with(|| {
- let mut signature = ir::Signature::new(CallConv::Patchable);
+ let mut signature = ir::Signature::new(CallConv::PreserveAll);
signature
.params
.push(ir::AbiParam::new(self.types.pointer_type));
@@ -93,6 +94,7 @@ impl BuiltinFunctions {
name,
signature,
colocated: true,
+ patchable: true,
})
})
}
@@ -1475,6 +1477,7 @@ impl FuncEnvironment<'_> {
name,
signature,
colocated: true,
+ patchable: false,
})
}
@@ -1515,6 +1518,7 @@ impl FuncEnvironment<'_> {
name,
signature,
colocated: true,
+ patchable: false,
})
}
@@ -3766,7 +3770,7 @@ impl FuncEnvironment<'_> {
if self.is_reachable() && self.state_slot.is_some() {
let builtin = self.builtin_functions.patchable_breakpoint(builder.func);
let vmctx = self.vmctx_val(&mut builder.cursor());
- let inst = builder.ins().patchable_call(builtin, &[vmctx]);
+ let inst = builder.ins().call(builtin, &[vmctx]);
let tags = self.debug_tags(builder.srcloc());
builder.func.debug_tags.set(inst, tags);
}