Commit Graph

70174 Commits

Author SHA1 Message Date
Alex Burka
c73bcf043e show macro backtrace with env var 2017-11-19 22:22:22 +00:00
bors
f50fd075c2 Auto merge of #45225 - eddyb:trans-abi, r=arielb1
Refactor type memory layouts and ABIs, to be more general and easier to optimize.

To combat combinatorial explosion, type layouts are now described through 3 orthogonal properties:
* `Variants` describes the plurality of sum types (where applicable)
  * `Single` is for one inhabited/active variant, including all C `struct`s and `union`s
  * `Tagged` has its variants discriminated by an integer tag, including C `enum`s
  * `NicheFilling` uses otherwise-invalid values ("niches") for all but one of its inhabited variants
* `FieldPlacement` describes the number and memory offsets of fields (if any)
  * `Union` has all its fields at offset `0`
  * `Array` has offsets that are a multiple of its `stride`; guarantees all fields have one type
  * `Arbitrary` records all the field offsets, which can be out-of-order
* `Abi` describes how values of the type should be passed around, including for FFI
  * `Uninhabited` corresponds to no values, associated with unreachable control-flow
  * `Scalar` is ABI-identical to its only integer/floating-point/pointer "scalar component"
  * `ScalarPair` has two "scalar components", but only applies to the Rust ABI
  * `Vector` is for SIMD vectors, typically `#[repr(simd)]` `struct`s in Rust
  * `Aggregate` has arbitrary contents, including all non-transparent C `struct`s and `union`s

Size optimizations implemented so far:
* ignoring uninhabited variants (i.e. containing uninhabited fields), e.g.:
  * `Option<!>` is 0 bytes
  * `Result<T, !>` has the same size as `T`
* using arbitrary niches, not just `0`, to represent a data-less variant, e.g.:
  * `Option<bool>`, `Option<Option<bool>>`, `Option<Ordering>` are all 1 byte
  * `Option<char>` is 4 bytes
* using a range of niches to represent *multiple* data-less variants, e.g.:
  * `enum E { A(bool), B, C, D }` is 1 byte

Code generation now takes advantage of `Scalar` and `ScalarPair` to, in more cases, pass around scalar components as immediates instead of indirectly, through pointers into temporary memory, while avoiding LLVM's "first-class aggregates", and there's more untapped potential here.

Closes #44426, fixes #5977, fixes #14540, fixes #43278.
2017-11-19 22:12:22 +00:00
Eduard-Mihai Burtescu
f9f5ab98b0 Revert "tests: Update run-make/issue-25581 to reflect how fat pointers are passed."
This reverts commit b12dcdef4f.
2017-11-19 23:38:48 +02:00
Steven Fackler
1e42d5f2e1 Add process::parent_id
I have this as a Unix-only API since it seems like Windows doesn't have
a similar API.
2017-11-19 12:36:55 -08:00
Basile Desloges
2285e35919 mir-borrowck: Use Field instead of usize for field index in user description functions 2017-11-19 20:19:11 +01:00
Basile Desloges
e5d291afbf mir-borrowck: Use bool for autoderef in append_lvalue_to_string() 2017-11-19 20:19:11 +01:00
Basile Desloges
094d67ee37 mir-borrowck: Remove parens in the lvalue description of a deref 2017-11-19 20:19:10 +01:00
Eduard-Mihai Burtescu
89e437354a rustc_trans: remove primitive_align optimization. 2017-11-19 20:33:46 +02:00
Zack M. Davis
1a9dc2e902 dead code lint to say "never constructed" for variants
As reported in #19140, #44083, and #44565, some users were confused when
the dead-code lint reported an enum variant to be "unused" when it was
matched on (but not constructed). This wording change makes it clearer
that the lint is in fact checking for construction.

We continue to say "used" for all other items (it's tempting to say
"called" for functions and methods, but this turns out not to be
correct: functions can be passed as arguments and the dead-code lint
isn't special-casing that or anything).

Resolves #19140.
2017-11-19 10:15:36 -08:00
bors
5041b3bb3d Auto merge of #45454 - Aaronepower:master, r=alexcrichton
Updated Release notes for 1.22.0

[rendered](https://github.com/Aaronepower/rust/blob/master/RELEASES.md)
2017-11-19 17:23:01 +00:00
Michael Woerister
8d6f869c98
Remove some trailing whitespace. 2017-11-19 17:26:19 +01:00
Michael Woerister
a4ad5dbcb7
Fix tidy line-length issue. 2017-11-19 17:12:04 +01:00
Eduard-Mihai Burtescu
88e4d2c291 rustc_trans: work around i686-pc-windows-msvc byval align LLVM bug. 2017-11-19 17:58:38 +02:00
bors
d8d5b6180f Auto merge of #46074 - scottmcm:unspecialize-nth, r=bluss
Undo the Sized specialization from Iterator::nth

I just added this as part of https://github.com/rust-lang/rust/pull/45595, but I'm now afraid there's a specialization issue with it, since I tried to add [another similar specialization](https://github.com/rust-lang/rust/compare/master...scottmcm:faster-iter-by-ref?expand=1#diff-1398f322bc563592215b583e9b0ba936R2390), and ended up getting really disturbing test failures like
```
thread 'iter::test_by_ref_folds' panicked at 'assertion failed: `(left == right)`
  left: `15`,
 right: `15`', src\libcore\../libcore/tests\iter.rs:1720:4
```

So since this wasn't the most critical part of the change and a new beta is branching within a week, I think putting this part back to what it was before is the best option.
2017-11-19 12:20:14 +00:00
Guillaume Gomez
ad6324f6f7 Fix path search in docs 2017-11-19 12:14:56 +01:00
Niko Matsakis
df6fdbc9ae fix closure inlining by spilling arguments to a temporary 2017-11-19 05:36:56 -05:00
Eduard-Mihai Burtescu
b0812de556 cargotest: temporarily use eddyb/servo to include servo/servo#19285. 2017-11-19 11:48:12 +02:00
Eduard-Mihai Burtescu
fb832833e2 Don't glob-import overlapping variant names in test/codegen/match-optimizes-away.rs. 2017-11-19 09:12:10 +02:00
Scott McMurray
57c0801e33 Add a MIR pass to lower 128-bit operators to lang item calls
Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet.
2017-11-18 21:51:14 -08:00
bors
c5c70ef723 Auto merge of #46064 - Keruspe:master, r=sfackler
update openssl{,-sys} to fix build with libressl 2.6.x
2017-11-19 05:19:10 +00:00
bors
8703e7d0e3 Auto merge of #46048 - cramertj:update-libc-2, r=alexcrichton
Update libc to include Fuchsia changes

This is an update of libc to include the updated Fuchsia "open" flags added in https://github.com/rust-lang/libc/pull/849.

cc @smklein
r? @alexcrichton
2017-11-19 03:02:15 +00:00
Eduard-Mihai Burtescu
95687bfe27 rustc_trans: (hack) use preferred alignment for atomic loads/stores. 2017-11-19 03:56:37 +02:00
Eduard-Mihai Burtescu
753d582f62 rustc: rename CachedLayout to LayoutDetails. 2017-11-19 02:43:56 +02:00
Eduard-Mihai Burtescu
8437d7c0f1 rustc: extend the niche-filling enum optimization past 2 variants. 2017-11-19 02:43:56 +02:00
Eduard-Mihai Burtescu
d893285b65 rustc: use layout::Abi::ScalarPair for structs in more cases. 2017-11-19 02:43:56 +02:00
Eduard-Mihai Burtescu
801a1a0fc1 rustc_trans: remove type_is_fat_ptr and its uses. 2017-11-19 02:43:56 +02:00
Eduard-Mihai Burtescu
fa67abd127 rustc: don't special-case Box<T> as having a pointer layout. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
18ecc564f2 rustc_trans: support scalar pairs directly in the Rust ABI. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
7a36141465 rustc: unpack scalar pair newtype layout ABIs. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
37a7521ef9 rustc: unpack scalar newtype layout ABIs. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
0b8697241f rustc_trans: be more relaxed with non-lvalue consumes, especially ZSTs. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
c4d9ada701 rustc: place ZSTs first during struct field reordering. 2017-11-19 02:43:55 +02:00
Eduard-Mihai Burtescu
cdeb4b0d25 rustc: encode scalar pairs in layout ABI. 2017-11-19 02:43:32 +02:00
Eduard-Mihai Burtescu
f1b7cd9925 rustc_trans: restrict "immediate pairs" to pairs of scalars. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
ac60872077 rustc_trans: generate LLVM pointee types based on alignment. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
f8d5d0c30c rustc_trans: compute better align/dereferenceable attributes from pointees. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
ced5e04e8b rustc: optimize out uninhabited types and variants. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
f62e43da28 rustc: track validity ranges for layout::Abi::Scalar values. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
5df25c4aed rustc: remove redundant/unused fields from layout::Abi::Vector. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
b203a26efb rustc: generalize layout::Variants::NicheFilling to niches other than 0. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
0190f270c1 rustc_trans: check for layout::I1 instead of TyBool. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
abbc1ddbd0 rustc: make TyLayout::field(NonZero<*T>, 0) return &T. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
de3e581e29 rustc: support u128 discriminant ranges. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
018323ffc2 rustc: collapse the remains of Layout into Variants (enums vs everything else). 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
b28f668e26 rustc: move size, align & primitive_align from Abi::Aggregate to layout. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
b723af284a rustc_trans: go through layouts uniformly for fat pointers and variants. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
026214c858 rustc: collapse Layout::FatPointer into Layout::Univariant. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
3fd6b00082 rustc_trans: query LLVM types from a layout instead of a Ty. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
1477119344 rustc_trans: keep a layout instead of a type in {Lvalue,Operand}Ref. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
88f70323e4 rustc_trans: nest abi::ArgType's for fat pointers instead of eagerly flattening. 2017-11-19 02:14:31 +02:00