Sync from rust 5e6de2369c82ed0b36e6b651b041bad5cb5e1ef8
This commit is contained in:
commit
d6b54a5433
@ -22,7 +22,19 @@ fn clif_sig_from_fn_abi<'tcx>(
|
||||
default_call_conv: CallConv,
|
||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
) -> Signature {
|
||||
let call_conv = match fn_abi.conv {
|
||||
let call_conv = conv_to_call_conv(fn_abi.conv, default_call_conv);
|
||||
|
||||
let inputs = fn_abi.args.iter().map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter()).flatten();
|
||||
|
||||
let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
|
||||
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
|
||||
let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect();
|
||||
|
||||
Signature { params, returns, call_conv }
|
||||
}
|
||||
|
||||
pub(crate) fn conv_to_call_conv(c: Conv, default_call_conv: CallConv) -> CallConv {
|
||||
match c {
|
||||
Conv::Rust | Conv::C => default_call_conv,
|
||||
Conv::RustCold => CallConv::Cold,
|
||||
Conv::X86_64SysV => CallConv::SystemV,
|
||||
@ -38,15 +50,8 @@ fn clif_sig_from_fn_abi<'tcx>(
|
||||
| Conv::X86VectorCall
|
||||
| Conv::AmdGpuKernel
|
||||
| Conv::AvrInterrupt
|
||||
| Conv::AvrNonBlockingInterrupt => todo!("{:?}", fn_abi.conv),
|
||||
};
|
||||
let inputs = fn_abi.args.iter().map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter()).flatten();
|
||||
|
||||
let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
|
||||
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
|
||||
let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect();
|
||||
|
||||
Signature { params, returns, call_conv }
|
||||
| Conv::AvrNonBlockingInterrupt => todo!("{:?}", c),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_function_sig<'tcx>(
|
||||
|
@ -45,7 +45,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
|
||||
if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
|
||||
all_constants_ok = false;
|
||||
match err {
|
||||
ErrorHandled::Reported(_) | ErrorHandled::Linted => {
|
||||
ErrorHandled::Reported(_) => {
|
||||
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
|
||||
}
|
||||
ErrorHandled::TooGeneric => {
|
||||
@ -126,7 +126,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
let layout = fx.layout_of(ty);
|
||||
assert!(!layout.is_unsized(), "sized const value");
|
||||
assert!(layout.is_sized(), "unsized const value");
|
||||
|
||||
if layout.is_zst() {
|
||||
return CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout);
|
||||
@ -393,7 +393,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
|
||||
data_ctx.define(bytes.into_boxed_slice());
|
||||
|
||||
for &(offset, alloc_id) in alloc.provenance().iter() {
|
||||
for &(offset, alloc_id) in alloc.provenance().ptrs().iter() {
|
||||
let addend = {
|
||||
let endianness = tcx.data_layout.endian;
|
||||
let offset = offset.bytes() as usize;
|
||||
@ -426,7 +426,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
{
|
||||
tcx.sess.fatal(&format!(
|
||||
"Allocation {:?} contains reference to TLS value {:?}",
|
||||
alloc, def_id
|
||||
alloc_id, def_id
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ impl DebugContext {
|
||||
|
||||
let producer = format!(
|
||||
"cg_clif (rustc {}, cranelift {})",
|
||||
rustc_interface::util::version_str().unwrap_or("unknown version"),
|
||||
rustc_interface::util::rustc_version_str().unwrap_or("unknown version"),
|
||||
cranelift_codegen::VERSION,
|
||||
);
|
||||
let comp_dir = tcx
|
||||
|
@ -63,10 +63,14 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
AbiParam::new(m.target_config().pointer_type()),
|
||||
],
|
||||
returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)],
|
||||
call_conv: CallConv::triple_default(m.isa().triple()),
|
||||
call_conv: crate::conv_to_call_conv(
|
||||
tcx.sess.target.options.entry_abi,
|
||||
CallConv::triple_default(m.isa().triple()),
|
||||
),
|
||||
};
|
||||
|
||||
let cmain_func_id = m.declare_function("main", Linkage::Export, &cmain_sig).unwrap();
|
||||
let entry_name = tcx.sess.target.options.entry_name.as_ref();
|
||||
let cmain_func_id = m.declare_function(entry_name, Linkage::Export, &cmain_sig).unwrap();
|
||||
|
||||
let instance = Instance::mono(tcx, rust_main_def_id).polymorphize(tcx);
|
||||
|
||||
|
@ -19,7 +19,7 @@ fn codegen_field<'tcx>(
|
||||
};
|
||||
|
||||
if let Some(extra) = extra {
|
||||
if !field_layout.is_unsized() {
|
||||
if field_layout.is_sized() {
|
||||
return simple(fx);
|
||||
}
|
||||
match field_layout.ty.kind() {
|
||||
@ -364,7 +364,7 @@ impl<'tcx> CPlace<'tcx> {
|
||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> CPlace<'tcx> {
|
||||
assert!(!layout.is_unsized());
|
||||
assert!(layout.is_sized());
|
||||
if layout.size.bytes() == 0 {
|
||||
return CPlace {
|
||||
inner: CPlaceInner::Addr(Pointer::dangling(layout.align.pref), None),
|
||||
@ -828,7 +828,7 @@ impl<'tcx> CPlace<'tcx> {
|
||||
fx: &FunctionCx<'_, '_, 'tcx>,
|
||||
variant: VariantIdx,
|
||||
) -> Self {
|
||||
assert!(!self.layout().is_unsized());
|
||||
assert!(self.layout().is_sized());
|
||||
let layout = self.layout().for_variant(fx, variant);
|
||||
CPlace { inner: self.inner, layout }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user