Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,8 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// Checks if these two `Layout` are equal enough to be considered "the same for all function
/// call ABIs". Note however that real ABIs depend on more details that are not reflected in the
/// `Layout`; the `PassMode` need to be compared as well. Also note that we assume
/// aggregates are passed via `PassMode::Indirect` or `PassMode::Cast`; more strict
/// checks would otherwise be required.
/// aggregates are passed via `PassMode::Indirect`, `PassMode::IndirectUnsized` or
/// `PassMode::Cast`; more strict checks would otherwise be required.
pub fn eq_abi(&self, other: &Self) -> bool {
// The one thing that we are not capturing here is that for unsized types, the metadata must
// also have the same ABI, and moreover that the same metadata leads to the same size. The
Expand Down
15 changes: 7 additions & 8 deletions compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
assert_eq!(pad_i32_count, 0, "padding support not yet implemented");
cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect()
}
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => {
PassMode::Indirect { attrs, address_space: _, mode } => {
assert!(
mode != IndirectMode::AmdgpuKernelArg,
"unsupported amdgpu kernel argument"
Expand All @@ -143,8 +143,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
smallvec![apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
}
}
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), address_space: _, mode } => {
assert!(mode == IndirectMode::Pointer);
PassMode::IndirectUnsized { attrs, meta_attrs } => {
smallvec![
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
Expand Down Expand Up @@ -188,7 +187,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
None,
cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect(),
),
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => {
PassMode::Indirect { attrs, address_space: _, mode } => {
assert!(mode == IndirectMode::Pointer);
(
Some(apply_attrs_to_abi_param(
Expand All @@ -198,7 +197,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
vec![],
)
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
}
Expand Down Expand Up @@ -268,7 +267,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
smallvec![a, b]
}
PassMode::Cast { ref cast, .. } => to_casted_value(fx, arg, cast),
PassMode::Indirect { .. } => {
PassMode::Indirect { .. } | PassMode::IndirectUnsized { .. } => {
if is_owned {
match arg.force_stack(fx) {
(ptr, None) => smallvec![ptr.get_addr(fx)],
Expand Down Expand Up @@ -328,7 +327,7 @@ pub(super) fn cvalue_for_param<'tcx>(
PassMode::Cast { ref cast, .. } => {
from_casted_value(fx, &block_params, arg_abi.layout, cast)
}
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs, address_space: _, mode: _ } => {
assert_eq!(block_params.len(), 1, "{:?}", block_params);
if let Some(pointee_align) = attrs.pointee_align
&& pointee_align < arg_abi.layout.align.abi
Expand All @@ -346,7 +345,7 @@ pub(super) fn cvalue_for_param<'tcx>(
CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout)
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
assert_eq!(block_params.len(), 2, "{:?}", block_params);
CValue::by_ref_unsized(Pointer::new(block_params[0]), block_params[1], arg_abi.layout)
}
Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_codegen_cranelift/src/abi/returning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub(super) fn codegen_return_param<'tcx>(
let is_ssa = ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.ret.layout.ty);
(super::make_local_place(fx, RETURN_PLACE, fx.fn_abi.ret.layout, is_ssa), smallvec![])
}
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
let ret_param = block_params_iter.next().unwrap();
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
(CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.ret.layout), smallvec![ret_param])
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
};
Expand Down Expand Up @@ -50,7 +50,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
) {
let (ret_temp_place, return_ptr) = match ret_arg_abi.mode {
PassMode::Ignore => (None, None),
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
if let Some(ret_ptr) = ret_place.try_to_ptr() {
// This is an optimization to prevent unnecessary copies of the return value when
// the return place is already a memory place as opposed to a register.
Expand All @@ -61,7 +61,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
(Some(place), Some(place.to_ptr().get_addr(fx)))
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => (None, None),
Expand All @@ -86,14 +86,14 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast);
ret_place.write_cvalue(fx, result);
}
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
if let Some(ret_temp_place) = ret_temp_place {
// If ret_temp_place is None, it is not necessary to copy the return value.
let ret_temp_value = ret_temp_place.to_cvalue(fx);
ret_place.write_cvalue(fx, ret_temp_value);
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
}
Expand All @@ -102,11 +102,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
/// Codegen a return instruction with the right return value(s) if any.
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
match fx.fn_abi.ret.mode {
PassMode::Ignore
| PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Ignore | PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
fx.bcx.ins().return_(&[]);
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
PassMode::Direct(_) => {
Expand Down
24 changes: 4 additions & 20 deletions compiler/rustc_codegen_gcc/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx)));
cx.type_void()
}
PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"),
};
#[cfg(feature = "master")]
let mut non_null_args = Vec::new();
Expand Down Expand Up @@ -189,12 +190,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
let ty = cast.gcc_type(cx);
apply_attrs(ty, &cast.attrs, argument_tys.len())
}
PassMode::Indirect {
attrs: _,
meta_attrs: None,
address_space: _,
mode: IndirectMode::OnStack,
} => {
PassMode::Indirect { attrs: _, address_space: _, mode: IndirectMode::OnStack } => {
let x86_interrupt_first_arg = {
#[cfg(feature = "master")]
{
Expand Down Expand Up @@ -223,7 +219,6 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}
PassMode::Indirect {
attrs: _,
meta_attrs: None,
address_space: _,
mode: IndirectMode::AmdgpuKernelArg,
} => {
Expand All @@ -232,21 +227,10 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
PassMode::Direct(attrs) => {
apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len())
}
PassMode::Indirect {
attrs,
meta_attrs: None,
address_space: _,
mode: IndirectMode::Pointer,
} => {
PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::Pointer } => {
apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len())
}
PassMode::Indirect {
attrs,
meta_attrs: Some(meta_attrs),
address_space: _,
mode,
} => {
assert!(mode == IndirectMode::Pointer);
PassMode::IndirectUnsized { attrs, meta_attrs } => {
// Construct the type of a (wide) pointer to `ty`, and pass its two fields.
// Any two ABI-compatible unsized types have the same metadata type and
// moreover the same metadata value leads to the same dynamic size and
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,10 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
PassMode::Pair(..) => {
OperandValue::Pair(next(), next()).store(bx, dst);
}
PassMode::Indirect { meta_attrs: Some(_), .. } => {
PassMode::IndirectUnsized { .. } => {
bug!("unsized `ArgAbi` cannot be stored");
}
PassMode::Direct(_)
| PassMode::Indirect { meta_attrs: None, .. }
| PassMode::Cast { .. } => {
PassMode::Direct(_) | PassMode::Indirect { .. } | PassMode::Cast { .. } => {
let next_arg = next();
self.store(bx, next_arg, dst);
}
Expand Down
Loading
Loading