1
Fork 0

Change the CallConv for "rust" abi functions to "SystemV" to match the "C" abi

The allocator machinery seems to mix "rust" and "C" abi function defs and calls.
This commit is contained in:
bjorn3 2018-12-11 15:13:45 +01:00
parent 74165046e8
commit dc2f32f985
2 changed files with 4 additions and 6 deletions

View file

@ -79,7 +79,7 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>(
unimpl!("Variadic function are not yet supported");
}
let (call_conv, inputs, output): (CallConv, Vec<Ty>, Ty) = match sig.abi {
Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()),
Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
Abi::RustCall => {
assert_eq!(sig.inputs().len(), 2);
@ -89,7 +89,7 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>(
};
let mut inputs: Vec<Ty> = vec![sig.inputs()[0]];
inputs.extend(extra_args.into_iter());
(CallConv::Fast, inputs, sig.output())
(CallConv::SystemV, inputs, sig.output())
}
Abi::System => bug!("system abi should be selected elsewhere"),
Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),

View file

@ -39,8 +39,8 @@ pub fn codegen(module: &mut Module<impl Backend + 'static>, kind: AllocatorKind)
}
};
let mut sig = Signature {
call_conv: CallConv::Fast,
let sig = Signature {
call_conv: CallConv::SystemV,
params: arg_tys.iter().cloned().map(AbiParam::new).collect(),
returns: output.into_iter().map(AbiParam::new).collect(),
};
@ -49,12 +49,10 @@ pub fn codegen(module: &mut Module<impl Backend + 'static>, kind: AllocatorKind)
let callee_name = kind.fn_name(method.name);
//eprintln!("Codegen allocator shim {} -> {} ({:?} -> {:?})", caller_name, callee_name, sig.params, sig.returns);
sig.call_conv = CallConv::Fast; // "rust" abi
let func_id = module
.declare_function(&caller_name, Linkage::Export, &sig)
.unwrap();
sig.call_conv = CallConv::SystemV; // "C" abi
let callee_func_id = module
.declare_function(&callee_name, Linkage::Import, &sig)
.unwrap();