Skip to content

Commit

Permalink
Rollup merge of rust-lang#57085 - glaubitz:sparc64-abi-fix, r=nagisa
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Centril committed Dec 24, 2018
2 parents 8b0b70d + 65dabd6 commit 6ce748a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc_codegen_llvm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -520,8 +523,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;
}
}
Expand Down

0 comments on commit 6ce748a

Please sign in to comment.