Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make i128 aligned to 16 bytes on all 64bit plats
Not sure if its minimal required alignment on non-x86_64 targets but extra alignment cannot
influence correctness, so its fine.
  • Loading branch information
nagisa committed Jan 6, 2017
commit f2e222cc84d83ed083c28f67af52827908ab8568
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn target() -> TargetResult {
llvm_target: "mips64-unknown-linux-gnuabi64".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "mips64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn target() -> TargetResult {
llvm_target: "mips64el-unknown-linux-gnuabi64".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "mips64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/powerpc64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "E-m:e-i64:64-n32:64".to_string(),
data_layout: "E-m:e-i64:64-i128:128-n32:64".to_string(),
arch: "powerpc64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-n32:64".to_string(),
data_layout: "e-m:e-i64:64-i128:128-n32:64".to_string(),
arch: "powerpc64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/s390x_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
llvm_target: "s390x-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(),
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-i128:128-f128:64-a:8:16-n32:64".to_string(),
arch: "s390x".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/sparc64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "sparc64-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".to_string(),
arch: "sparc64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/sparc64_unknown_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "sparc64-unknown-netbsd".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".to_string(),
arch: "sparc64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_apple_darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:o-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "macos".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:o-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_pc_windows_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:w-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "windows".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:w-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "windows".to_string(),
target_env: "msvc".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_rumprun_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-rumprun-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_sun_solaris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-pc-solaris".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "solaris".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_bitrig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-bitrig".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "bitrig".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_dragonfly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "dragonfly".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "freebsd".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-fuchsia".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "fuchsia".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_haiku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-haiku".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "haiku".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "linux".to_string(),
target_env: "musl".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_openbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-openbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "openbsd".to_string(),
target_env: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_redox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> TargetResult {
llvm_target: "x86_64-unknown-redox".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
data_layout: "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "redox".to_string(),
target_env: "".to_string(),
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,11 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
// FIXME(#34960)
let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
let custom_llvm_used = cfg_llvm_root.trim() != "";
// Ignore any `-i128:128` that we add to our own data-layouts
let this_dl = sess.target.target.data_layout.replace("-i128:128", "");
let that_dl = data_layout.replace("-i128:128", "");

if !custom_llvm_used && sess.target.target.data_layout != data_layout {
if !custom_llvm_used && this_dl != that_dl {
bug!("data-layout for builtin `{}` target, `{}`, \
differs from LLVM default, `{}`",
sess.target.target.llvm_target,
Expand Down
4 changes: 4 additions & 0 deletions src/rt/rust_test_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ struct Foo adt_id(struct Foo foo) {
return foo;
}

struct Foo adt_clone(struct Foo *foo) {
return *foo;
}

unsigned __int128 identity(unsigned __int128 a) {
return a;
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-pass/i128-ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern "C" {
fn square(f: i128) -> i128;
fn sub(f: i128, f: i128) -> i128;
fn adt_id(f: Foo) -> Foo;
fn adt_clone(f: *const Foo) -> Foo;
}

fn main() {
Expand All @@ -53,5 +54,7 @@ fn main() {
let a = Foo { a: 1, b: 2, c: 3 };
let b = adt_id(a);
assert_eq!(a, b);
let b = adt_clone(&a);
assert_eq!(a, b);
}
}