Skip to content

Commit e985396

Browse files
committed
llvm: Match aarch64 data layout to new LLVM layout
LLVM has added 3 new address spaces to support special Windows use cases. These shouldn't trouble us for now, but LLVM requires matching data layouts. See llvm/llvm-project#111879 for details
1 parent a0c2aba commit e985396

39 files changed

+72
-38
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ pub(crate) unsafe fn create_module<'ll>(
138138
}
139139
}
140140

141+
if llvm_version < (20, 0, 0) {
142+
if sess.target.arch == "aarch64" || sess.target.arch.starts_with("arm64") {
143+
// LLVM 20 defines three additional address spaces for alternate
144+
// pointer kinds used in Windows.
145+
// See https://github.com/llvm/llvm-project/pull/111879
146+
target_data_layout =
147+
target_data_layout.replace("-p270:32:32-p271:32:32-p272:64:64", "");
148+
}
149+
}
150+
141151
// Ensure the data-layout values hardcoded remain the defaults.
142152
{
143153
let tm = crate::back::write::create_informational_target_machine(tcx.sess, false);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
mcount: "\u{1}mcount".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a7".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a12".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a7".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a7".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a7".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(false),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a16".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(false),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+neon,+fp-armv8,+apple-a16".into(),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub(crate) fn target() -> Target {
1212
std: Some(true),
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
15+
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
16+
.into(),
1617
arch,
1718
options: TargetOptions {
1819
features: "+v8a,+neon,+fp-armv8,+apple-a7".into(),

0 commit comments

Comments
 (0)