Rollup merge of #142389 - beetrees:cranelift-arg-ext, r=bjorn3

Apply ABI attributes on return types in `rustc_codegen_cranelift`

- The [x86-64 System V ABI standard](https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build) doesn't sign/zero-extend integer arguments or return types.
- But the de-facto standard as implemented by Clang and GCC is to sign/zero-extend arguments to 32 bits (but not return types).
- Additionally, Apple targets [sign/zero-extend both arguments and return values to 32 bits](https://developer.apple.com/documentation/xcode/writing-64-bit-intel-code-for-apple-platforms#Pass-arguments-to-functions-correctly).
- However, the `rustc_target` ABI adjustment code currently [unconditionally extends both arguments and return values to 32 bits](https://github.com/rust-lang/rust/blame/e703dff8fe220b78195c53478e83fb2f68d8499c/compiler/rustc_target/src/callconv/x86_64.rs#L240) on all targets.
- This doesn't cause a miscompilation when compiling with LLVM as LLVM will ignore the `signext`/`zeroext` attribute when applied to return types on non-Apple x86-64 targets.
- Cranelift, however, does not have a similar special case, requiring `rustc` to set the argument extension attribute correctly.
- However, `rustc_codegen_cranelift` doesn't currently apply ABI attributes to return types at all, meaning `rustc_codegen_cranelift` will currently miscompile `i8`/`u8`/`i16`/`u16` returns on x86-64 Apple targets as those targets require sign/zero-extension of return types.

This PR fixes the bug(s) by making the `rustc_target` x86-64 System V ABI only mark return types as sign/zero-extended on Apple platforms, while also making `rustc_codegen_cranelift` apply ABI attributes to return types. The RISC-V and s390x C ABIs also require sign/zero extension of return types, so this will fix those targets when building with `rustc_codegen_cranelift` too.

r? `````@bjorn3`````
This commit is contained in:
León Orell Valerian Liehr 2025-06-15 23:51:56 +02:00 committed by GitHub
commit 16152661ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 1161 additions and 27 deletions

View file

@ -1,6 +1,6 @@
//! Argument passing
use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
use cranelift_codegen::ir::ArgumentPurpose;
use rustc_abi::{Reg, RegKind};
use rustc_target::callconv::{
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
@ -32,13 +32,12 @@ fn reg_to_abi_param(reg: Reg) -> AbiParam {
AbiParam::new(clif_ty)
}
fn apply_arg_attrs_to_abi_param(mut param: AbiParam, arg_attrs: ArgAttributes) -> AbiParam {
fn apply_attrs_to_abi_param(param: AbiParam, arg_attrs: ArgAttributes) -> AbiParam {
match arg_attrs.arg_ext {
RustcArgExtension::None => {}
RustcArgExtension::Zext => param.extension = ArgumentExtension::Uext,
RustcArgExtension::Sext => param.extension = ArgumentExtension::Sext,
RustcArgExtension::None => param,
RustcArgExtension::Zext => param.uext(),
RustcArgExtension::Sext => param.sext(),
}
param
}
fn cast_target_to_abi_params(cast: &CastTarget) -> SmallVec<[AbiParam; 2]> {
@ -82,7 +81,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
match self.mode {
PassMode::Ignore => smallvec![],
PassMode::Direct(attrs) => match self.layout.backend_repr {
BackendRepr::Scalar(scalar) => smallvec![apply_arg_attrs_to_abi_param(
BackendRepr::Scalar(scalar) => smallvec![apply_attrs_to_abi_param(
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
attrs
)],
@ -97,8 +96,8 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
let a = scalar_to_clif_type(tcx, a);
let b = scalar_to_clif_type(tcx, b);
smallvec![
apply_arg_attrs_to_abi_param(AbiParam::new(a), attrs_a),
apply_arg_attrs_to_abi_param(AbiParam::new(b), attrs_b),
apply_attrs_to_abi_param(AbiParam::new(a), attrs_a),
apply_attrs_to_abi_param(AbiParam::new(b), attrs_b),
]
}
_ => unreachable!("{:?}", self.layout.backend_repr),
@ -112,19 +111,19 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
// Abi requires aligning struct size to pointer size
let size = self.layout.size.align_to(tcx.data_layout.pointer_align.abi);
let size = u32::try_from(size.bytes()).unwrap();
smallvec![apply_arg_attrs_to_abi_param(
smallvec![apply_attrs_to_abi_param(
AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructArgument(size),),
attrs
)]
} else {
smallvec![apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
smallvec![apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
}
}
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
assert!(!on_stack);
smallvec![
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
]
}
}
@ -133,30 +132,46 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
fn get_abi_return(&self, tcx: TyCtxt<'tcx>) -> (Option<AbiParam>, Vec<AbiParam>) {
match self.mode {
PassMode::Ignore => (None, vec![]),
PassMode::Direct(_) => match self.layout.backend_repr {
BackendRepr::Scalar(scalar) => {
(None, vec![AbiParam::new(scalar_to_clif_type(tcx, scalar))])
}
PassMode::Direct(attrs) => match self.layout.backend_repr {
BackendRepr::Scalar(scalar) => (
None,
vec![apply_attrs_to_abi_param(
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
attrs,
)],
),
BackendRepr::SimdVector { .. } => {
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
(None, vec![AbiParam::new(vector_ty)])
(None, vec![apply_attrs_to_abi_param(AbiParam::new(vector_ty), attrs)])
}
_ => unreachable!("{:?}", self.layout.backend_repr),
},
PassMode::Pair(_, _) => match self.layout.backend_repr {
PassMode::Pair(attrs_a, attrs_b) => match self.layout.backend_repr {
BackendRepr::ScalarPair(a, b) => {
let a = scalar_to_clif_type(tcx, a);
let b = scalar_to_clif_type(tcx, b);
(None, vec![AbiParam::new(a), AbiParam::new(b)])
(
None,
vec![
apply_attrs_to_abi_param(AbiParam::new(a), attrs_a),
apply_attrs_to_abi_param(AbiParam::new(b), attrs_b),
],
)
}
_ => unreachable!("{:?}", self.layout.backend_repr),
},
PassMode::Cast { ref cast, .. } => {
(None, cast_target_to_abi_params(cast).into_iter().collect())
}
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack } => {
PassMode::Indirect { attrs, meta_attrs: None, on_stack } => {
assert!(!on_stack);
(Some(AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn)), vec![])
(
Some(apply_attrs_to_abi_param(
AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn),
attrs,
)),
vec![],
)
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
unreachable!("unsized return value")

View file

@ -7,6 +7,7 @@ use rustc_abi::{
};
use crate::callconv::{ArgAbi, CastTarget, FnAbi};
use crate::spec::HasTargetSpec;
/// Classification of "eightbyte" components.
// N.B., the order of the variants is from general to specific,
@ -175,7 +176,7 @@ const MAX_SSE_REGS: usize = 8; // XMM0-7
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,
C: HasDataLayout + HasTargetSpec,
{
let mut int_regs = MAX_INT_REGS;
let mut sse_regs = MAX_SSE_REGS;
@ -236,7 +237,7 @@ where
if arg.layout.is_aggregate() {
let size = arg.layout.size;
arg.cast_to(cast_target(cls, size));
} else {
} else if is_arg || cx.target_spec().is_like_darwin {
arg.extend_integer_width_to(32);
}
}

View file

@ -19,7 +19,7 @@ pub fn call_other_fn() -> u8 {
}
// CHECK-LABEL: other_fn:
// CHECK: callq *foreign_fn@GOTPCREL(%rip)
// CHECK: {{(jmpq|callq)}} *foreign_fn@GOTPCREL(%rip)
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {

View file

@ -22,7 +22,7 @@ pub fn call_other_fn() -> u8 {
// CHECK-LABEL: other_fn:
// External functions are still called through GOT, since we don't know if the symbol
// is defined in the binary or in the shared library.
// CHECK: callq *foreign_fn@GOTPCREL(%rip)
// CHECK: {{(jmpq|callq)}} *foreign_fn@GOTPCREL(%rip)
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {

View file

@ -13,7 +13,7 @@ pub fn call_foreign_fn() -> u8 {
// External functions are still marked as non-dso_local, since we don't know if the symbol
// is defined in the binary or in the shared library.
// CHECK: declare zeroext i8 @foreign_fn()
// CHECK: declare i8 @foreign_fn()
extern "C" {
fn foreign_fn() -> u8;
}

View file

@ -0,0 +1,536 @@
error: fn_abi_of(i8) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
true,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776123356184577,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
true,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776123356184577,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:13:1
|
LL | pub extern "sysv64" fn i8(x: i8) -> i8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u8) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776127651151873,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776127651151873,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:19:1
|
LL | pub extern "sysv64" fn u8(x: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(i16) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
true,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462603027808258,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
true,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462603027808258,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:25:1
|
LL | pub extern "sysv64" fn i16(x: i16) -> i16 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u16) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
false,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462607322775554,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
false,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462607322775554,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:31:1
|
LL | pub extern "sysv64" fn u16(x: u16) -> u16 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(i32) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462603027873795,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462603027873795,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:37:1
|
LL | pub extern "sysv64" fn i32(x: i32) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u32) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462607322841091,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462607322841091,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:43:1
|
LL | pub extern "sysv64" fn u32(x: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View file

@ -0,0 +1,536 @@
error: fn_abi_of(i8) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
true,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776123356184577,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
true,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776123356184577,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:13:1
|
LL | pub extern "sysv64" fn i8(x: i8) -> i8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u8) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776127651151873,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
randomization_seed: 71776127651151873,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:19:1
|
LL | pub extern "sysv64" fn u8(x: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(i16) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
true,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462603027808258,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Sext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
true,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462603027808258,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:25:1
|
LL | pub extern "sysv64" fn i16(x: i16) -> i16 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u16) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
false,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462607322775554,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: Zext,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u16,
layout: Layout {
size: Size(2 bytes),
align: AbiAlign {
abi: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I16,
false,
),
valid_range: 0..=65535,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(2 bytes),
randomization_seed: 18446462607322775554,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:31:1
|
LL | pub extern "sysv64" fn u16(x: u16) -> u16 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(i32) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462603027873795,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: i32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462603027873795,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:37:1
|
LL | pub extern "sysv64" fn i32(x: i32) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(u32) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462607322841091,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: Size(4 bytes),
align: AbiAlign {
abi: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
randomization_seed: 18446462607322841091,
},
},
mode: Direct(
ArgAttributes {
regular: NoUndef,
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: X86(
SysV64,
),
can_unwind: false,
}
--> $DIR/x86-64-sysv64-arg-ext.rs:43:1
|
LL | pub extern "sysv64" fn u32(x: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View file

@ -0,0 +1,46 @@
//@ only-x86_64
//@ revisions: apple other
//@[apple] only-apple
//@[other] ignore-apple
// Apple targets extend up to 32 bits for both arguments and returns, other targets only extend
// arguments.
#![crate_type = "lib"]
#![feature(rustc_attrs)]
#[rustc_abi(debug)]
pub extern "sysv64" fn i8(x: i8) -> i8 {
//~^ ERROR fn_abi_of(i8)
x
}
#[rustc_abi(debug)]
pub extern "sysv64" fn u8(x: u8) -> u8 {
//~^ ERROR fn_abi_of(u8)
x
}
#[rustc_abi(debug)]
pub extern "sysv64" fn i16(x: i16) -> i16 {
//~^ ERROR fn_abi_of(i16)
x
}
#[rustc_abi(debug)]
pub extern "sysv64" fn u16(x: u16) -> u16 {
//~^ ERROR fn_abi_of(u16)
x
}
#[rustc_abi(debug)]
pub extern "sysv64" fn i32(x: i32) -> i32 {
//~^ ERROR fn_abi_of(i32)
x
}
#[rustc_abi(debug)]
pub extern "sysv64" fn u32(x: u32) -> u32 {
//~^ ERROR fn_abi_of(u32)
x
}