librustc_codegen_llvm: Don't eliminate empty structs in C ABI on linux-sparc64
authorMichael Karcher <github@mkarcher.dialup.fu-berlin.de>
Sun, 23 Dec 2018 19:33:52 +0000 (20:33 +0100)
committerXimin Luo <infinity0@debian.org>
Mon, 28 Jan 2019 06:02:48 +0000 (06:02 +0000)
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.

Gbp-Pq: Name u-0001-librustc_codegen_llvm-Don-t-eliminate-empty-structs-.patch

src/librustc_codegen_llvm/abi.rs

index 5b6d157043d864ad6b8195d38acbdb2c395fe941..b8d37ad458f31f66db4a4da286d7cad9603847a4 100644 (file)
@@ -456,6 +456,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
         let linux_s390x = target.target_os == "linux"
                        && target.arch == "s390x"
                        && target.target_env == "gnu";
+        let linux_sparc64 = target.target_os == "linux"
+                       && target.arch == "sparc64"
+                       && target.target_env == "gnu";
         let rust_abi = match sig.abi {
             RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true,
             _ => false
@@ -526,8 +529,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
             if arg.layout.is_zst() {
                 // For some forsaken reason, x86_64-pc-windows-gnu
                 // doesn't ignore zero-sized struct arguments.
-                // The same is true for s390x-unknown-linux-gnu.
-                if is_return || rust_abi || (!win_x64_gnu && !linux_s390x) {
+                // The same is true for s390x-unknown-linux-gnu
+                // and sparc64-unknown-linux-gnu.
+                if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
                     arg.mode = PassMode::Ignore;
                 }
             }