mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Auto merge of #116672 - maurer:128-align, r=nikic
LLVM 18 x86 data layout update With https://reviews.llvm.org/D86310 LLVM now has i128 aligned to 16-bytes on x86 based platforms. This will be in LLVM-18. This patch updates all our spec targets to be 16-byte aligned, and removes the alignment when speaking to older LLVM. This results in Rust overaligning things relative to LLVM on older LLVMs. This implements MCP https://github.com/rust-lang/compiler-team/issues/683. See #54341
This commit is contained in:
commit
0547c41f90
@ -3304,9 +3304,13 @@ mod size_asserts {
|
||||
static_assert_size!(Impl, 136);
|
||||
static_assert_size!(Item, 136);
|
||||
static_assert_size!(ItemKind, 64);
|
||||
static_assert_size!(LitKind, 24);
|
||||
// This can be removed after i128:128 is in the bootstrap compiler's target.
|
||||
#[cfg(not(bootstrap))]
|
||||
static_assert_size!(LitKind, 32);
|
||||
static_assert_size!(Local, 72);
|
||||
static_assert_size!(MetaItemLit, 40);
|
||||
// This can be removed after i128:128 is in the bootstrap compiler's target.
|
||||
#[cfg(not(bootstrap))]
|
||||
static_assert_size!(MetaItemLit, 48);
|
||||
static_assert_size!(Param, 40);
|
||||
static_assert_size!(Pat, 72);
|
||||
static_assert_size!(Path, 24);
|
||||
|
@ -145,6 +145,14 @@ pub unsafe fn create_module<'ll>(
|
||||
.replace("-Fi64", "");
|
||||
}
|
||||
}
|
||||
if llvm_version < (18, 0, 0) {
|
||||
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
|
||||
// LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.
|
||||
// Earlier LLVMs leave this as default alignment, so remove it.
|
||||
// See https://reviews.llvm.org/D86310
|
||||
target_data_layout = target_data_layout.replace("-i128:128", "");
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the data-layout values hardcoded remain the defaults.
|
||||
if sess.target.is_builtin {
|
||||
|
@ -1672,13 +1672,19 @@ mod size_asserts {
|
||||
use super::*;
|
||||
use rustc_data_structures::static_assert_size;
|
||||
// tidy-alphabetical-start
|
||||
static_assert_size!(BasicBlockData<'_>, 136);
|
||||
// This can be removed after i128:128 is in the bootstrap compiler's target.
|
||||
#[cfg(not(bootstrap))]
|
||||
static_assert_size!(BasicBlockData<'_>, 144);
|
||||
static_assert_size!(LocalDecl<'_>, 40);
|
||||
static_assert_size!(SourceScopeData<'_>, 72);
|
||||
static_assert_size!(Statement<'_>, 32);
|
||||
static_assert_size!(StatementKind<'_>, 16);
|
||||
static_assert_size!(Terminator<'_>, 104);
|
||||
static_assert_size!(TerminatorKind<'_>, 88);
|
||||
// This can be removed after i128:128 is in the bootstrap compiler's target.
|
||||
#[cfg(not(bootstrap))]
|
||||
static_assert_size!(Terminator<'_>, 112);
|
||||
// This can be removed after i128:128 is in the bootstrap compiler's target.
|
||||
#[cfg(not(bootstrap))]
|
||||
static_assert_size!(TerminatorKind<'_>, 96);
|
||||
static_assert_size!(VarDebugInfo<'_>, 88);
|
||||
// tidy-alphabetical-end
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: ios_sim_llvm_target(arch).into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:128-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:128-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { max_atomic_width: Some(64), ..opts("ios", arch) },
|
||||
|
@ -5,7 +5,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i586-pc-unknown".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: TargetOptions {
|
||||
|
@ -10,7 +10,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i586-unknown-netbsdelf".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: TargetOptions { mcount: "__mcount".into(), ..base },
|
||||
|
@ -18,7 +18,7 @@ pub fn target() -> Target {
|
||||
llvm_target: macos_llvm_target(Arch::I686).into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:128-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:128-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { mcount: "\u{1}mcount".into(), ..base },
|
||||
|
@ -17,7 +17,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-linux-android".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
|
||||
|
@ -19,7 +19,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:32-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -18,7 +18,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:32-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -25,7 +25,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-msvc".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:128-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-freebsd".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-haiku".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-hurd-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -12,7 +12,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-linux-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -25,7 +25,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-linux-musl".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-netbsdelf".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: TargetOptions { mcount: "__mcount".into(), ..base },
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-openbsd".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -80,7 +80,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-windows-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:32-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
|
||||
|
@ -18,7 +18,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:32-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -9,7 +9,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-msvc".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:128-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -25,7 +25,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-pc-windows-msvc".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:128-n8:16:32-a:0:32-S32"
|
||||
i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -11,7 +11,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "i686-unknown-linux-gnu".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
f64:32:64-f80:32-n8:16:32-S128"
|
||||
i128:128-f64:32:64-f80:32-n8:16:32-S128"
|
||||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: base,
|
||||
|
@ -17,8 +17,8 @@ pub fn target() -> Target {
|
||||
// correctly, we do too.
|
||||
llvm_target: macos_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { mcount: "\u{1}mcount".into(), ..base },
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: ios_sim_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { max_atomic_width: Some(128), ..base },
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: llvm_target.into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { max_atomic_width: Some(128), ..base },
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: tvos_sim_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { max_atomic_width: Some(128), ..opts("tvos", arch) },
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: watchos_sim_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { max_atomic_width: Some(128), ..opts("watchos", arch) },
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-elf".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: opts,
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-linux-android".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-unknown".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: TargetOptions {
|
||||
cpu: "x86-64".into(),
|
||||
|
@ -13,8 +13,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-solaris".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-gnu".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-gnu".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-msvc".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ pub fn target() -> Target {
|
||||
llvm_target: "x86_64-unknown-linux-musl".into(),
|
||||
pointer_width: 64,
|
||||
arch: "x86_64".into(),
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
options: TargetOptions {
|
||||
cpu: "x86-64".into(),
|
||||
plt_by_default: false,
|
||||
|
@ -11,8 +11,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-dragonfly".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-freebsd".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-fuchsia".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-haiku".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ pub fn target() -> Target {
|
||||
llvm_target: "x86_64-unknown-hermit".into(),
|
||||
pointer_width: 64,
|
||||
arch: "x86_64".into(),
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
options: TargetOptions {
|
||||
cpu: "x86-64".into(),
|
||||
features: "+rdrnd,+rdseed".into(),
|
||||
|
@ -13,8 +13,8 @@ pub fn target() -> Target {
|
||||
// so we still pass Solaris to it
|
||||
llvm_target: "x86_64-pc-solaris".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-l4re-uclibc".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-linux-gnu".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub fn target() -> Target {
|
||||
llvm_target: "x86_64-unknown-linux-gnux32".into(),
|
||||
pointer_width: 32,
|
||||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
|
||||
i64:64-f80:128-n8:16:32:64-S128"
|
||||
i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
|
@ -18,8 +18,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-linux-musl".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ pub fn target() -> Target {
|
||||
// LLVM 15 doesn't support OpenHarmony yet, use a linux target instead.
|
||||
llvm_target: "x86_64-unknown-linux-musl".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-netbsd".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: TargetOptions { mcount: "__mcount".into(), ..base },
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-none-elf".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: opts,
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-openbsd".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-redox".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-windows".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
|
||||
options: base,
|
||||
|
@ -15,8 +15,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-gnu".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-msvc".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-win7-windows-msvc".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-linux-gnu".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: "x86_64".into(),
|
||||
options: base,
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ pub fn target() -> Target {
|
||||
// correctly, we do too.
|
||||
llvm_target: macos_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
.into(),
|
||||
data_layout:
|
||||
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions { mcount: "\u{1}mcount".into(), ..base },
|
||||
}
|
||||
|
103
tests/codegen/i128-x86-align.rs
Normal file
103
tests/codegen/i128-x86-align.rs
Normal file
@ -0,0 +1,103 @@
|
||||
// only-x86_64
|
||||
// compile-flags: -O -C no-prepopulate-passes --crate-type=lib
|
||||
|
||||
// On LLVM 17 and earlier LLVM's own data layout specifies that i128 has 8 byte alignment,
|
||||
// while rustc wants it to have 16 byte alignment. This test checks that we handle this
|
||||
// correctly.
|
||||
|
||||
// CHECK: %ScalarPair = type { i32, [3 x i32], i128 }
|
||||
// CHECK: %Struct = type { i32, i32, [2 x i32], i128 }
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ScalarPair {
|
||||
a: i32,
|
||||
b: i128,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn load(x: &ScalarPair) -> ScalarPair {
|
||||
// CHECK-LABEL: @load(
|
||||
// CHECK-SAME: align 16 dereferenceable(32) %x
|
||||
// CHECK: [[A:%.*]] = load i32, ptr %x, align 16
|
||||
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16
|
||||
// CHECK-NEXT: [[B:%.*]] = load i128, ptr [[GEP]], align 16
|
||||
// CHECK-NEXT: [[IV1:%.*]] = insertvalue { i32, i128 } poison, i32 [[A]], 0
|
||||
// CHECK-NEXT: [[IV2:%.*]] = insertvalue { i32, i128 } [[IV1]], i128 [[B]], 1
|
||||
// CHECK-NEXT: ret { i32, i128 } [[IV2]]
|
||||
*x
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn store(x: &mut ScalarPair) {
|
||||
// CHECK-LABEL: @store(
|
||||
// CHECK-SAME: align 16 dereferenceable(32) %x
|
||||
// CHECK: store i32 1, ptr %x, align 16
|
||||
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16
|
||||
// CHECK-NEXT: store i128 2, ptr [[GEP]], align 16
|
||||
*x = ScalarPair { a: 1, b: 2 };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn alloca() {
|
||||
// CHECK-LABEL: @alloca(
|
||||
// CHECK: [[X:%.*]] = alloca %ScalarPair, align 16
|
||||
// CHECK: store i32 1, ptr %x, align 16
|
||||
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16
|
||||
// CHECK-NEXT: store i128 2, ptr [[GEP]], align 16
|
||||
let mut x = ScalarPair { a: 1, b: 2 };
|
||||
store(&mut x);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn load_volatile(x: &ScalarPair) -> ScalarPair {
|
||||
// CHECK-LABEL: @load_volatile(
|
||||
// CHECK-SAME: align 16 dereferenceable(32) %x
|
||||
// CHECK: [[TMP:%.*]] = alloca %ScalarPair, align 16
|
||||
// CHECK: [[LOAD:%.*]] = load volatile %ScalarPair, ptr %x, align 16
|
||||
// CHECK-NEXT: store %ScalarPair [[LOAD]], ptr [[TMP]], align 16
|
||||
// CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP]], align 16
|
||||
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16
|
||||
// CHECK-NEXT: [[B:%.*]] = load i128, ptr [[GEP]], align 16
|
||||
unsafe { std::intrinsics::volatile_load(x) }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn transmute(x: ScalarPair) -> (std::mem::MaybeUninit<i128>, i128) {
|
||||
// CHECK-LABEL: define { i128, i128 } @transmute(i32 noundef %x.0, i128 noundef %x.1)
|
||||
// CHECK: [[TMP:%.*]] = alloca { i128, i128 }, align 16
|
||||
// CHECK-NEXT: store i32 %x.0, ptr [[TMP]], align 16
|
||||
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16
|
||||
// CHECK-NEXT: store i128 %x.1, ptr [[GEP]], align 16
|
||||
// CHECK-NEXT: [[LOAD1:%.*]] = load i128, ptr %_0, align 16
|
||||
// CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16
|
||||
// CHECK-NEXT: [[LOAD2:%.*]] = load i128, ptr [[GEP2]], align 16
|
||||
// CHECK-NEXT: [[IV1:%.*]] = insertvalue { i128, i128 } poison, i128 [[LOAD1]], 0
|
||||
// CHECK-NEXT: [[IV2:%.*]] = insertvalue { i128, i128 } [[IV1]], i128 [[LOAD2]], 1
|
||||
// CHECK-NEXT: ret { i128, i128 } [[IV2]]
|
||||
unsafe { std::mem::transmute(x) }
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Struct {
|
||||
a: i32,
|
||||
b: i32,
|
||||
c: i128,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn store_struct(x: &mut Struct) {
|
||||
// CHECK-LABEL: @store_struct(
|
||||
// CHECK-SAME: align 16 dereferenceable(32) %x
|
||||
// CHECK: [[TMP:%.*]] = alloca %Struct, align 16
|
||||
// CHECK: store i32 1, ptr [[TMP]], align 16
|
||||
// CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds %Struct, ptr [[TMP]], i32 0, i32 1
|
||||
// CHECK-NEXT: store i32 2, ptr [[GEP1]], align 4
|
||||
// CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds %Struct, ptr [[TMP]], i32 0, i32 3
|
||||
// CHECK-NEXT: store i128 3, ptr [[GEP2]], align 16
|
||||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 16 %x, ptr align 16 [[TMP]], i64 32, i1 false)
|
||||
*x = Struct { a: 1, b: 2, c: 3 };
|
||||
}
|
Loading…
Reference in New Issue
Block a user