8000 Rollup of 25 pull requests by pietroalbini · Pull Request #56051 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 25 pull requests #56051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f3e9b1a
in which the E0618 "expected function" diagnostic gets a makeover
zackmdavis Nov 11, 2018
b7c319c
do not panic just because cargo failed
RalfJung Nov 11, 2018
0671bdb
reword #[test] attribute error on fn items
zeegomo Nov 11, 2018
0c08529
A few tweaks to iterations/collecting
ljedrz Nov 5, 2018
562be7e
Forward the ABI of the non-zero sized fields of an union if they have…
ogoffart Nov 8, 2018
cfbae3e
core/tests/num: Simplify `test_int_from_str_overflow()` test code
Turbo87 Nov 13, 2018
57a7c85
miri: backtraces with instances
RalfJung Nov 14, 2018
2ec6f34
Update CI-clang to 7.0.0 for Linux dists.
michaelwoerister Nov 14, 2018
f6b8eb7
Update CI-clang to 7.0.0 for macOS dists.
michaelwoerister Nov 14, 2018
fb5135a
prettier miri backtrace printing
RalfJung Nov 14, 2018
1ca505a
capture_disjoint_fields(rust-lang#53488)
blitzerr Nov 14, 2018
c040a48
Remove extern and some return value as an attempt to make the test pa…
ogoffart Nov 14, 2018
b396505
put file and line into miri backtrace
RalfJung Nov 14, 2018
aa3d7a4
properly calculate spans for intra-doc link resolution errors
QuietMisdreavus Nov 15, 2018
a1f83e7
Stress test for MPSC
stepancheg Nov 15, 2018
7f4bc22
Clean up some non-mod-rs stuff.
ehuss Oct 16, 2018
6779bb4
capture_disjoint_fields(rust-lang#53488)
blitzerr Nov 15, 2018
c5bc83b
expose MutValueVisitor
RalfJung Nov 13, 2018
e4d03f8
miri value visitor: provide place when visiting a primitive
RalfJung Nov 13, 2018
62cf9ab
rename FrameInfo span field to call_site
RalfJung Nov 15, 2018
e6e5635
ty: return impl Iterator from Predicate::walk_tys
ljedrz Nov 14, 2018
ffb6ba0
validation: better error when the enum discriminant is Undef
RalfJung Nov 12, 2018
a3770c2
do not accept out-of-bounds pointers in enum discriminants, they migh…
RalfJung Nov 12, 2018
b8915f2
fix other affected tests
RalfJung Nov 12, 2018
81303d7
Add powerpc-unknown-linux-musl target
smaeul Sep 10, 2018
346e976
Fix powerpc64 ELFv2 big-endian struct-passing ABI
smaeul Sep 16, 2018
2bb5029
Use the ELFv2 ABI on powerpc64 musl
smaeul Aug 9, 2018
4f9c860
Add powerpc64-unknown-linux-musl target
smaeul Aug 8, 2018
8c8ff6a
test/linkage-visibility: Ignore on musl targets
smaeul Sep 16, 2018
03aaa4b
remove unused dependency
andjo403 Nov 10, 2018
303dbcc
CTFE: dynamically make sure we do not call non-const-fn
RalfJung Nov 16, 2018
c1221e2
Replace data.clone() by Arc::clone(&data) in mutex doc.
CBenoit Nov 16, 2018
0c0478d
adjust remaining tests
RalfJung Nov 16, 2018
41434e0
avoid shared ref in UnsafeCell::get
RalfJung Nov 16, 2018
a7b312f
erase the tag on casts involving (raw) pointers
RalfJung Nov 17, 2018
25d46f3
add comment explaining why what we do is legal
RalfJung Nov 17, 2018
2b7c3fb
add test for #[test] attribute only allowed on non associated functions
zeegomo Nov 17, 2018
8e13e43
tidy check fix
zeegomo Nov 17, 2018
5fc63ce
docs: Add missing backtick in object_safety.rs docs
Xanewok Nov 17, 2018
cdb1a79
Add VecDeque::resize_with
scottmcm Nov 17, 2018
a5b4cb2
remove "approx env bounds" if we already know from trait
nikomatsakis Nov 18, 2018
36e1d9f
Rollup merge of #55562 - smaeul:powerpc-linux-musl, r=alexcrichton
pietroalbini Nov 18, 2018
21ff709
Rollup merge of #55564 - smaeul:test-fixes-2, r=alexcrichton
pietroalbini Nov 18, 2018
9c3e8d3
Rollup merge of #55827 - ljedrz:various_stashed, r=alexcrichton
pietroalbini Nov 18, 2018
4a52c56
Rollup merge of #55834 - ogoffart:union-abi, r=eddyb
pietroalbini Nov 18, 2018
7130947
Rollup merge of #55857 - andjo403:rmdep, r=Mark-Simulacrum
pietroalbini Nov 18, 2018
9577734
Rollup merge of #55862 - zackmdavis:but_will_they_come_when_you_call_…
pietroalbini Nov 18, 2018
3aeac24
Rollup merge of #55867 - RalfJung:dont-panic, r=Mark-Simulacrum
pietroalbini Nov 18, 2018
131a755
Rollup merge of #55894 - RalfJung:validation-enums, r=oli-obk
pietroalbini Nov 18, 2018
c87c31b
Rollup merge of #55916 - RalfJung:mut-visitor, r=oli-obk
pietroalbini Nov 18, 2018
5e2ff63
Rollup merge of #55919 - Turbo87:num-tests, r=dtolnay
pietroalbini Nov 18, 2018
715d83f
Rollup merge of #55923 - Zeegomo:master, r=estebank
pietroalbini Nov 18, 2018
8607325
Increase `Duration` approximate equal threshold to 1us
alexcrichton Nov 19, 2018
fc30ab4
Rollup merge of #55949 - ljedrz:return_impl_Iterator_from_Predicate_w…
pietroalbini Nov 18, 2018
32e4eb9
Rollup merge of #55952 - michaelwoerister:newer-clang, r=alexcrichton
pietroalbini Nov 18, 2018
989d06a < 8000 div class="text-emphasized css-truncate css-truncate-target"> Rollup merge of #55953 - blitzerr:master, r=nikomatsakis
pietroalbini Nov 18, 2018
f13d166
Rollup merge of #55962 - QuietMisdreavus:tricky-spans, r=GuillaumeGomez
pietroalbini Nov 18, 2018
318a38e
Rollup merge of #55963 - stepancheg:mpsc-take-2, r=alexcrichton
pietroalbini Nov 18, 2018
6ecbb05
Rollup merge of #55968 - ehuss:non-mod-rs-tests, r=petrochenkov
pietroalbini Nov 18, 2018
cc6473d
Rollup merge of #55970 - RalfJung:miri-backtrace, r=@oli-obk
pietroalbini Nov 18, 2018
c0d48ce
Rollup merge of #56007 - RalfJung:non-const-call, r=oli-obk
pietroalbini Nov 18, 2018
05ae505
Rollup merge of #56011 - CBenoit:master, r=QuietMisdreavus
pietroalbini Nov 18, 2018
2a68c00
Rollup merge of #56012 - RalfJung:unsafe-cell, r=nikomatsakis
pietroalbini Nov 18, 2018
f5dc12e
Rollup merge of #56016 - scottmcm:vecdeque-resize-with, r=joshtriplett
pietroalbini Nov 18, 2018
27519c1
Rollup merge of #56027 - Xanewok:docs-backtick, r=QuietMisdreavus
pietroalbini Nov 18, 2018
10565c4
Rollup merge of #56043 - nikomatsakis:issue-55756-via-outlives, r=eddyb
pietroalbini Nov 18, 2018
8cea658
Rollup merge of #56059 - alexcrichton:fix-tests, r=sfackler
kennytm Nov 19, 2018
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
8000
Prev Previous commit
Next Next commit
Forward the ABI of the non-zero sized fields of an union if they have…
… the same ABI

This is supposed to fix the performence regression of using MaybeUninit in
#54668
  • Loading branch information
ogoffart committed Nov 13, 2018
commit 562be7e1a1955742d61320d0855550794c4b6c22
35 changes: 34 additions & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
Align::from_bytes(repr_align, repr_align).unwrap());
}

let optimize = !def.repr.inhibit_union_abi_opt();
let mut size = Size::ZERO;
let mut abi = Abi::Aggregate { sized: true };
let index = VariantIdx::new(0);
for field in &variants[index] {
assert!(!field.is_unsized());
Expand All @@ -708,13 +710,44 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
} else {
align = align.max(field.align);
}

// If all non-ZST fields have the same ABI, forward this ABI
if optimize && !field.is_zst() {
// Normalize scalar_unit to the maximal valid range
let field_abi = match &field.abi {
Abi::Scalar(x) => Abi::Scalar(scalar_unit(x.value)),
Abi::ScalarPair(x, y) => {
Abi::ScalarPair(
scalar_unit(x.value),
scalar_unit(y.value),
)
}
Abi::Vector { element: x, count } => {
Abi::Vector {
element: scalar_unit(x.value),
count: *count,
}
}
Abi::Uninhabited |
Abi::Aggregate { .. } => Abi::Aggregate { sized: true },
};

if size == Size::ZERO {
// first non ZST: initialize 'abi'
abi = field_abi;
} else if abi != field_abi {
// different fields have different ABI: reset to Aggregate
abi = Abi::Aggregate { sized: true };
}
}

size = cmp::max(size, field.size);
}

return Ok(tcx.intern_layout(LayoutDetails {
variants: Variants::Single { index },
fields: FieldPlacement::Union(variants[index].len()),
abi: Abi::Aggregate { sized: true },
abi,
align,
size: size.abi_align(align)
}));
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,12 @@ impl ReprOptions {
pub fn inhibit_struct_field_reordering_opt(&self) -> bool {
!(self.flags & ReprFlags::IS_UNOPTIMISABLE).is_empty() || (self.pack == 1)
}

/// Returns true if this `#[repr()]` should inhibit union abi optimisations
pub fn inhibit_union_abi_opt(&self) -> bool {
self.c()
}

}

impl<'a, 'gcx, 'tcx> AdtDef {
Expand Down
80 changes: 80 additions & 0 deletions src/test/codegen/union-abi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -C no-prepopulate-passes

// This test that using union forward the abi of the inner type, as
// discussed in #54668

#![crate_type="lib"]
#![feature(repr_simd)]

#[derive(Copy, Clone)]
pub enum Unhab {}

#[repr(simd)]
#[derive(Copy, Clone)]
pub struct i64x4(i64, i64, i64, i64);

#[derive(Copy, Clone)]
pub union UnionI64x4{ a:(), b: i64x4 }

// CHECK: define <4 x i64> @test_UnionI64x4(<4 x i64> %arg0)
#[no_mangle]
pub extern fn test_UnionI64x4(_: UnionI64x4) -> UnionI64x4 { loop {} }

pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 }

// CHECK: define <4 x i64> @test_UnionI64x4_(<4 x i64> %arg0)
#[no_mangle]
pub extern fn test_UnionI64x4_(_: UnionI64x4_) -> UnionI64x4_ { loop {} }

pub union UnionI64x4I64{ a: i64x4, b: i64 }

// CHECK: define void @test_UnionI64x4I64(%UnionI64x4I64* {{.*}} %arg0)
#[no_mangle]
pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} }

pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) }

// CHECK: define void @test_UnionI64x4Tuple(%UnionI64x4Tuple* {{.*}} %arg0)
#[no_mangle]
pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} }


pub union UnionF32{a:f32}

// CHECK: define float @test_UnionF32(float %arg0)
#[no_mangle]
pub extern fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }

pub union UnionF32F32{a:f32, b:f32}

// CHECK: define float @test_UnionF32F32(float %arg0)
#[no_mangle]
pub extern fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} }

pub union UnionF32U32{a:f32, b:u32}

// CHECK: define i32 @test_UnionF32U32(i32)
#[no_mangle]
pub extern fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} }

pub union UnionU128{a:u128}
// CHECK: define i128 @test_UnionU128(i128 %arg0)
#[no_mangle]
pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} }

#[repr(C)]
pub union CUnionU128{a:u128}
// CHECK: define void @test_CUnionU128(%CUnionU128* {{.*}} %arg0)
#[no_mangle]
pub fn test_CUnionU128(_: CUnionU128) { loop {} }

0