Skip to content

Commit 6ce748a

Browse files
authored
Rollup merge of rust-lang#57085 - glaubitz:sparc64-abi-fix, r=nagisa
librustc_codegen_llvm: Don't eliminate empty structs in C ABI on linux-sparc64 This is in accordance with the SPARC Compliance Definition 2.4.1, Page 3P-12. It says that structs of up to 8 bytes (which applies to empty structs as well) are to be passed in one register.
2 parents 8b0b70d + 65dabd6 commit 6ce748a

File tree

1 file changed

+6
-2
lines changed
  • src/librustc_codegen_llvm

1 file changed

+6
-2
lines changed

src/librustc_codegen_llvm/abi.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
456456
let linux_s390x = target.target_os == "linux"
457457
&& target.arch == "s390x"
458458
&& target.target_env == "gnu";
459+
let linux_sparc64 = target.target_os == "linux"
460+
&& target.arch == "sparc64"
461+
&& target.target_env == "gnu";
459462
let rust_abi = match sig.abi {
460463
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true,
461464
_ => false
@@ -520,8 +523,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
520523
if arg.layout.is_zst() {
521524
// For some forsaken reason, x86_64-pc-windows-gnu
522525
// doesn't ignore zero-sized struct arguments.
523-
// The same is true for s390x-unknown-linux-gnu.
524-
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x) {
526+
// The same is true for s390x-unknown-linux-gnu
527+
// and sparc64-unknown-linux-gnu.
528+
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
525529
arg.mode = PassMode::Ignore;
526530
}
527531
}

0 commit comments

Comments
 (0)