Skip to content

Commit 39296ff

Browse files
committed
s390x: Support aligned stack datalayout
LLVM 23 will mark the stack as aligned for more efficient code: llvm/llvm-project#176041
1 parent 5c49c4f commit 39296ff

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ pub(crate) unsafe fn create_module<'ll>(
216216
target_data_layout = target_data_layout.replace("-f64:32:64", "");
217217
}
218218
}
219+
if llvm_version < (23, 0, 0) {
220+
if sess.target.arch == Arch::S390x {
221+
// LLVM 23 updated the s390x layout to specify the stack alignment: https://github.com/llvm/llvm-project/pull/176041
222+
target_data_layout = target_data_layout.replace("-S64", "");
223+
}
224+
}
219225

220226
// Ensure the data-layout values hardcoded remain the defaults.
221227
{

compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
2222
std: Some(true),
2323
},
2424
pointer_width: 64,
25-
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
25+
data_layout: "E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
2626
arch: Arch::S390x,
2727
options: base,
2828
}

compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
2323
std: Some(true),
2424
},
2525
pointer_width: 64,
26-
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
26+
data_layout: "E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
2727
arch: Arch::S390x,
2828
options: base,
2929
}

0 commit comments

Comments
 (0)