Skip to content

Commit 588a25a

Browse files
authored
Rollup merge of rust-lang#102499 - cuviper:llvm-16-s390x, r=nikic
Adjust the s390x data layout for LLVM 16 LLVM [D131158] changed the SystemZ data layout to always set 64-bit vector alignment, which used to be conditional on the "vector" feature. [D131158]: https://reviews.llvm.org/D131158 r? `@nikic`
2 parents e36c3c1 + 2e7a964 commit 588a25a

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Diff for: compiler/rustc_codegen_llvm/src/context.rs

+5
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ pub unsafe fn create_module<'ll>(
154154
target_data_layout = target_data_layout.replace("-p10:8:8-p20:8:8", "");
155155
}
156156
}
157+
if llvm_version < (16, 0, 0) {
158+
if sess.target.arch == "s390x" {
159+
target_data_layout = target_data_layout.replace("-v128:64", "");
160+
}
161+
}
157162

158163
// Ensure the data-layout values hardcoded remain the defaults.
159164
if sess.target.is_builtin {

Diff for: compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The data_layout string below and the ABI implementation in
10-
// cabi_s390x.rs are for now hard-coded to assume the no-vector ABI.
11-
// Pass the -vector feature string to LLVM to respect this assumption.
9+
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11+
// also strip v128 from the data_layout below to match the older LLVM's expectation.
1212
base.features = "-vector".into();
1313
base.max_atomic_width = Some(64);
1414
base.min_global_align = Some(16);
@@ -17,7 +17,7 @@ pub fn target() -> Target {
1717
Target {
1818
llvm_target: "s390x-unknown-linux-gnu".into(),
1919
pointer_width: 64,
20-
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(),
20+
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
2121
arch: "s390x".into(),
2222
options: base,
2323
}

Diff for: compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The data_layout string below and the ABI implementation in
10-
// cabi_s390x.rs are for now hard-coded to assume the no-vector ABI.
11-
// Pass the -vector feature string to LLVM to respect this assumption.
9+
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11+
// also strip v128 from the data_layout below to match the older LLVM's expectation.
1212
base.features = "-vector".into();
1313
base.max_atomic_width = Some(64);
1414
base.min_global_align = Some(16);
@@ -18,7 +18,7 @@ pub fn target() -> Target {
1818
Target {
1919
llvm_target: "s390x-unknown-linux-musl".into(),
2020
pointer_width: 64,
21-
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(),
21+
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
2222
arch: "s390x".into(),
2323
options: base,
2424
}

0 commit comments

Comments
 (0)