Skip to content

Commit 65dabd6

Browse files
karchermglaubitz
authored andcommitted
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.
1 parent ddab10a commit 65dabd6

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
@@ -526,8 +529,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
526529
if arg.layout.is_zst() {
527530
// For some forsaken reason, x86_64-pc-windows-gnu
528531
// doesn't ignore zero-sized struct arguments.
529-
// The same is true for s390x-unknown-linux-gnu.
530-
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x) {
532+
// The same is true for s390x-unknown-linux-gnu
533+
// and sparc64-unknown-linux-gnu.
534+
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
531535
arg.mode = PassMode::Ignore;
532536
}
533537
}

0 commit comments

Comments
 (0)