Rollup merge of #136985 - zachs18:backend-repr-remove-uninhabited, r=workingjubilee
Do not ignore uninhabited types for function-call ABI purposes. (Remove BackendRepr::Uninhabited) Accepted MCP: https://github.com/rust-lang/compiler-team/issues/832 Fixes #135802 Do not consider the inhabitedness of a type for function call ABI purposes. * Remove the [`rustc_abi::BackendRepr::Uninhabited`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/enum.BackendRepr.html) variant * Instead calculate the `BackendRepr` of uninhabited types "normally" (as though they were not uninhabited "at the top level", but still considering inhabitedness of variants to determine enum layout, etc) * Add an `uninhabited: bool` field to [`rustc_abi::LayoutData`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/struct.LayoutData.html) so inhabitedness of a `LayoutData` can still be queried when necessary (e.g. when determining if an enum variant needs a tag value allocated to it). This should not affect type layouts (size/align/field offset); this should only affect function call ABI, and only of uninhabited types. cc ``@RalfJung``
This commit is contained in:
commit
8c9e3749a1
49 changed files with 532 additions and 167 deletions
|
@ -80,7 +80,7 @@ where
|
|||
}
|
||||
}
|
||||
},
|
||||
BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv),
|
||||
BackendRepr::Vector { .. } => return Err(CannotUseFpConv),
|
||||
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields {
|
||||
FieldsShape::Primitive => {
|
||||
unreachable!("aggregates can't have `FieldsShape::Primitive`")
|
||||
|
|
|
@ -38,7 +38,7 @@ mod xtensa;
|
|||
pub enum PassMode {
|
||||
/// Ignore the argument.
|
||||
///
|
||||
/// The argument is either uninhabited or a ZST.
|
||||
/// The argument is a ZST.
|
||||
Ignore,
|
||||
/// Pass the argument directly.
|
||||
///
|
||||
|
@ -350,7 +350,6 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
|||
scalar_attrs: impl Fn(&TyAndLayout<'a, Ty>, Scalar, Size) -> ArgAttributes,
|
||||
) -> Self {
|
||||
let mode = match layout.backend_repr {
|
||||
BackendRepr::Uninhabited => PassMode::Ignore,
|
||||
BackendRepr::Scalar(scalar) => {
|
||||
PassMode::Direct(scalar_attrs(&layout, scalar, Size::ZERO))
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ where
|
|||
}
|
||||
}
|
||||
},
|
||||
BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv),
|
||||
BackendRepr::Vector { .. } => return Err(CannotUseFpConv),
|
||||
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields {
|
||||
FieldsShape::Primitive => {
|
||||
unreachable!("aggregates can't have `FieldsShape::Primitive`")
|
||||
|
|
|
@ -108,9 +108,7 @@ where
|
|||
Ty: TyAbiInterface<'a, C> + Copy,
|
||||
{
|
||||
match layout.backend_repr {
|
||||
BackendRepr::Uninhabited
|
||||
| BackendRepr::Scalar(_)
|
||||
| BackendRepr::ScalarPair(..) => false,
|
||||
BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) => false,
|
||||
BackendRepr::Vector { .. } => true,
|
||||
BackendRepr::Memory { .. } => {
|
||||
for i in 0..layout.fields.count() {
|
||||
|
|
|
@ -51,8 +51,6 @@ where
|
|||
}
|
||||
|
||||
let mut c = match layout.backend_repr {
|
||||
BackendRepr::Uninhabited => return Ok(()),
|
||||
|
||||
BackendRepr::Scalar(scalar) => match scalar.primitive() {
|
||||
Primitive::Int(..) | Primitive::Pointer(_) => Class::Int,
|
||||
Primitive::Float(_) => Class::Sse,
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::spec::{HasTargetSpec, RustcAbi};
|
|||
pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
|
||||
let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| {
|
||||
match a.layout.backend_repr {
|
||||
BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {}
|
||||
BackendRepr::Memory { sized: false } => {}
|
||||
BackendRepr::ScalarPair(..) | BackendRepr::Memory { sized: true } => {
|
||||
match a.layout.size.bits() {
|
||||
8 => a.cast_to(Reg::i8()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue