From 1d6e62e1e240714a2f9fb4343d667fca6dbc313e Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Mon, 4 Dec 2023 16:39:22 +0100 Subject: [PATCH 1/2] Fixes ICE in sparc64 ABI (Issue #115399) --- compiler/rustc_target/src/abi/call/sparc64.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/abi/call/sparc64.rs b/compiler/rustc_target/src/abi/call/sparc64.rs index cbed5b4afc134..97d48a79aebfa 100644 --- a/compiler/rustc_target/src/abi/call/sparc64.rs +++ b/compiler/rustc_target/src/abi/call/sparc64.rs @@ -98,7 +98,7 @@ fn parse_structure<'a, Ty, C>( cx: &C, layout: TyAndLayout<'a, Ty>, mut data: Sdata, - mut offset: Size, + offset: Size, ) -> Sdata where Ty: TyAbiInterface<'a, C> + Copy, @@ -115,9 +115,15 @@ where abi::Abi::Aggregate { .. } => { for i in 0..layout.fields.count() { if offset < layout.fields.offset(i) { - offset = layout.fields.offset(i); + data = parse_structure( + cx, + layout.field(cx, i), + data.clone(), + layout.fields.offset(i), + ); + } else { + data = parse_structure(cx, layout.field(cx, i), data.clone(), offset); } - data = parse_structure(cx, layout.field(cx, i), data.clone(), offset); } } _ => { From e4d3ac14218753b1cf4a3d587c9b8266f1fb2f79 Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Thu, 7 Dec 2023 16:35:49 +0100 Subject: [PATCH 2/2] trying to enable disabled sparc64 ui/abi tests --- tests/ui/abi/compatibility.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index d5f0531307838..7edc1e01b7389 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -265,7 +265,6 @@ test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32); // Compatibility of 1-ZST. test_abi_compatible!(zst_unit, Zst, ()); -#[cfg(not(any(target_arch = "sparc64")))] test_abi_compatible!(zst_array, Zst, [u8; 0]); test_abi_compatible!(nonzero_int, NonZeroI32, i32); @@ -306,7 +305,7 @@ test_transparent!(zst, Zst); test_transparent!(unit, ()); test_transparent!(enum_, Option); test_transparent!(enum_niched, Option<&'static i32>); -#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] +#[cfg(not(target_arch = "mips64"))] mod tuples { use super::*; // mixing in some floats since they often get special treatment @@ -320,7 +319,7 @@ mod tuples { test_transparent!(tuple, (i32, f32, i64, f64)); } // Some targets have special rules for arrays. -#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] +#[cfg(not(target_arch = "mips64"))] mod arrays { use super::*; test_transparent!(empty_array, [u32; 0]); @@ -342,7 +341,7 @@ macro_rules! test_transparent_unsized { }; } -#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] +#[cfg(not(target_arch = "mips64"))] mod unsized_ { use super::*; test_transparent_unsized!(str_, str);