Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit acd839d

Browse files
authoredNov 1, 2024
Rollup merge of #132422 - maurer:sparc-layout, r=durin42
llvm: Match new LLVM 128-bit integer alignment on sparc LLVM continues to align more 128-bit integers to 128-bits in the data layout rather than relying on the high level language to do it. Update SPARC target files to match and add a backcompat replacement for current LLVMs. See llvm/llvm-project#106951 for details `@rustbot` label: +llvm-main r? `@durin42` (Please wait for the LLVM CI to come back before approving), creating this PR to get it tested there.
2 parents a25ab33 + 9caced7 commit acd839d

7 files changed

+11
-6
lines changed
 

‎compiler/rustc_codegen_llvm/src/context.rs

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ pub(crate) unsafe fn create_module<'ll>(
148148
target_data_layout =
149149
target_data_layout.replace("-p270:32:32-p271:32:32-p272:64:64", "");
150150
}
151+
if sess.target.arch.starts_with("sparc") {
152+
// LLVM 20 updates the sparc layout to correctly align 128 bit integers to 128 bit.
153+
// See https://github.com/llvm/llvm-project/pull/106951
154+
target_data_layout = target_data_layout.replace("-i128:128", "");
155+
}
151156
}
152157

153158
// Ensure the data-layout values hardcoded remain the defaults.

‎compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616
std: Some(true),
1717
},
1818
pointer_width: 64,
19-
data_layout: "E-m:e-i64:64-n32:64-S128".into(),
19+
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
2020
arch: "sparc64".into(),
2121
options: base,
2222
}

‎compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616
std: Some(true),
1717
},
1818
pointer_width: 64,
19-
data_layout: "E-m:e-i64:64-n32:64-S128".into(),
19+
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
2020
arch: "sparc64".into(),
2121
options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
2222
}

‎compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
std: Some(true),
1818
},
1919
pointer_width: 64,
20-
data_layout: "E-m:e-i64:64-n32:64-S128".into(),
20+
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
2121
arch: "sparc64".into(),
2222
options: base,
2323
}

‎compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn target() -> Target {
1111
std: Some(true),
1212
},
1313
pointer_width: 32,
14-
data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(),
14+
data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(),
1515
arch: "sparc".into(),
1616
options: TargetOptions {
1717
cpu: "v9".into(),

‎compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
..Default::default()
1818
};
1919
Target {
20-
data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(),
20+
data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(),
2121
llvm_target: "sparc-unknown-none-elf".into(),
2222
metadata: crate::spec::TargetMetadata {
2323
description: Some("Bare 32-bit SPARC V7+".into()),

‎compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
1919
std: Some(true),
2020
},
2121
pointer_width: 64,
22-
data_layout: "E-m:e-i64:64-n32:64-S128".into(),
22+
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
2323
// Use "sparc64" instead of "sparcv9" here, since the former is already
2424
// used widely in the source base. If we ever needed ABI
2525
// differentiation from the sparc64, we could, but that would probably

0 commit comments

Comments
 (0)
Failed to load comments.