Commit Graph

436 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu 961fe5479f rustc: use indexmap instead of a plain vector for upvars. 2019-06-01 19:17:22 +03:00
Eduard-Mihai Burtescu 26e61dd826 rustc: replace Res in hir::Upvar with only Local/Upvar data. 2019-06-01 19:01:09 +03:00
Mazdak Farrokhzad dcfc15b23c
Rollup merge of #61249 - spastorino:local-or-deref-local, r=oli-obk,Centril
Rename Place::local to Place::local_or_deref_local

r? @oli-obk
2019-05-29 08:15:59 +02:00
Mazdak Farrokhzad ee08261c8c
Rollup merge of #60928 - TheSirC:fix/60229, r=eddyb
Changes the type `mir::Mir` into `mir::Body`

Fixes part 1 of #60229 (previously attempted in #60242).

I stumbled upon the issue and it seems that the previous attempt at solving it was not merged. This is a second try more up-to-date.

The commit should have changed comments as well.
At the time of writting, it passes the tidy and check tool.
2019-05-29 00:19:55 +02:00
Claude-Alban RANÉLY-VERGÉ-DÉPRÉ 6e5e0daff2 Changes the type `mir::Mir` into `mir::Body`
The commit should have changed comments as well.
At the time of writting, it passes the tidy and check tool.

Revisions asked by eddyb :
- Renamed of all the occurences of {visit/super}_mir
- Renamed test structures `CachedMir` to `Cached`

Fixing the missing import on `AggregateKind`
2019-05-28 19:17:51 +02:00
Santiago Pastorino 5e4d83e972 Rename Place::local to Place::local_or_deref_local 2019-05-28 18:50:55 +02:00
Ralf Jung 082da0c698 rename Scalar::Bits to Scalar::Raw and bits field to data 2019-05-26 11:08:03 +02:00
Oliver Scherer e694b63cd1 Don't use `ty::Const` without immediately interning 2019-05-25 10:07:01 +02:00
Oliver Scherer 8d4f4cdada Reuse the pretty printing architecture for printing of constants 2019-05-25 10:07:01 +02:00
Edd Barrett 123a456a4f Make place projections concrete.
Once upon a time (commit 9bd35c07c2) there were two kinds of
projection: one for places, and one for constants. It therefore made
sense to share the `Projection` struct for both. Although the different
use-cases used different concrete types, sharing was made possible by
type-parameterisation of `Projection`.

Since then, however, the usage of projections in constants has
disappeared, meaning that (forgetting lifetimes for a moment) the
parameterised type is only every instantiated under one guise. So it may
as well be a concrete type.
2019-05-24 14:14:36 +01:00
Matthew Jasper ebd6c7164e Dont show variables from desugarings in borrowck errors 2019-05-21 20:38:17 +01:00
Vadim Petrochenkov 88fa5c6a45 Improve type size assertions
Now they
- Tell what the new size is, when it changes
- Do not require passing an identifier
2019-05-19 13:59:44 +03:00
Eduard-Mihai Burtescu 8d9f4a128c rustc: rename all occurences of "freevar" to "upvar". 2019-05-05 18:49:32 +03:00
Eduard-Mihai Burtescu 125dc60dab rustc: replace uses of with_freevars with the freevars query. 2019-05-05 18:48:42 +03:00
Mazdak Farrokhzad 0399d1349e
Rollup merge of #60486 - spastorino:place-related-refactors, r=oli-obk
Place related refactors

Meanwhile I was working on Place 2 I'm finding some little things that I had on my branch but preferred to land a separate PR for things that are simpler to merge.

r? @oli-obk
2019-05-04 09:21:24 +02:00
bors e232636693 Auto merge of #59897 - tmandry:variantful-generators, r=eddyb
Multi-variant layouts for generators

This allows generators to overlap fields using variants, but doesn't do any such overlapping yet. It creates one variant for every state of the generator (unresumed, returned, panicked, plus one for every yield), and puts every stored local in each of the yield-point variants.

Required for optimizing generator layouts (#52924).

There was quite a lot of refactoring needed for this change. I've done my best in later commits to eliminate assumptions in the code that only certain kinds of types are multi-variant, and to centralize knowledge of the inner mechanics of generators in as few places as possible.

This change also emits debuginfo about the fields contained in each variant, as well as preserving debuginfo about stored locals while running in the generator.

Also, fixes #59972.

Future work:
- Use this change for an optimization pass that actually overlaps locals within the generator struct (#52924)
- In the type layout fields, don't include locals that are uninitialized for a particular variant, so miri and UB sanitizers can check our memory (see https://github.com/rust-lang/rust/issues/59972#issuecomment-483058172)
- Preserve debuginfo scopes across generator yield points
2019-05-04 03:18:14 +00:00
Tyler Mandry 77a6d29f48 Address review comments 2019-05-03 19:25:35 -07:00
Tyler Mandry 15dbe652ff Split out debuginfo from type info in MIR GeneratorLayout 2019-05-03 16:03:05 -07:00
Tyler Mandry f7c2f2475a Make variant_fields inner an IndexVec 2019-05-03 14:25:22 -07:00
Santiago Pastorino 49f0141374 Implement base_local iteratively 2019-05-02 22:52:43 +02:00
bors e8310a7714 Auto merge of #60167 - varkor:tidy-filelength, r=matthewjasper
Add a tidy check for files with over 3,000 lines

Files with a large number of lines can cause issues in GitHub (e.g. https://github.com/rust-lang/rust/issues/60015) and also tend to be indicative of opportunities to refactor into less monolithic structures.

This adds a new check to tidy to warn against files that have more than 3,000 lines, as suggested in https://github.com/rust-lang/rust/issues/60015#issuecomment-483868594. (This number was chosen fairly arbitrarily as a reasonable indicator of size.) This check can be ignored with `// ignore-tidy-filelength`.

Existing files with greater than 3,000 lines currently ignore the check, but this helps us spot when files are getting too large. (We might try to split up all files larger than this in the future, as in https://github.com/rust-lang/rust/issues/60015).
2019-04-26 04:42:10 +00:00
varkor aa388f1d11 ignore-tidy-filelength on all files with greater than 3000 lines 2019-04-25 21:39:09 +01:00
Tyler Mandry f772c39bf9 Include generator locals as field names in debuginfo 2019-04-25 10:28:09 -07:00
Tyler Mandry 5a7af5480c Support variantful generators
This allows generators to overlap fields using variants.
2019-04-25 10:28:09 -07:00
Tyler Mandry 4de2d8a869 Give GeneratorLayout a list of fields for each variant
But don't really use it yet.
2019-04-25 10:23:15 -07:00
Santiago Pastorino 72cda98e48 Implement Debug for Place using Place::iterate 2019-04-25 14:45:59 +02:00
Eduard-Mihai Burtescu 1525dc2146 rustc: dissuade compiler developers from misusing upvar debuginfo. 2019-04-23 23:35:21 +03:00
Eduard-Mihai Burtescu 82bd7196c2 rustc: don't track var_hir_id or mutability in mir::UpvarDecl. 2019-04-23 23:35:15 +03:00
bors 72bc62047f Auto merge of #59987 - saleemjaffer:refactor_adjust_castkinds, r=oli-obk
Refactor Adjust and CastKind

fixes rust-lang#59588
2019-04-20 15:06:15 +00:00
Santiago Pastorino 0a386baa5f Make PlaceProjectionsIter a proper iterator 2019-04-18 03:04:57 +02:00
Santiago Pastorino b461740f03 Make iterate take a FnOnce with PlaceBase and PlaceProjectionIter 2019-04-17 19:44:17 +02:00
Santiago Pastorino 0326f0a803 Place::iterate do not take an accumulator anymore, hide that in a private fn 2019-04-17 19:44:17 +02:00
Santiago Pastorino 53fa32fe50 Place::unroll -> Place::iterate 2019-04-17 19:44:17 +02:00
Santiago Pastorino 66fe4ff7d5 Move unroll_place to Place::unroll 2019-04-17 19:44:17 +02:00
Saleem Jaffer 5be6b0beb9 basic refactor. Adding PointerCast enum 2019-04-15 20:29:13 +05:30
Mazdak Farrokhzad 27adc935fb
Rollup merge of #59877 - Zoxc:hiridify_def_id, r=eddyb
HirIdify hir::Def

cc @ljedrz
r? @oli-obk
2019-04-14 17:49:19 +02:00
ljedrz 3b99a48c4d HirIdify hir::Def 2019-04-14 09:30:02 +02:00
Nicholas Nethercote fd7f605365 Increase `Span` from 4 bytes to 8 bytes.
This increases the size of some important types, such as `ast::Expr` and
`mir::Statement`. However, it drastically reduces how much the interner
is used, and the fields are more natural sizes that don't require bit
operations to extract.

As a result, instruction counts drop across a range of workloads, by as
much as 12% for incremental "check" builds of `script-servo`.

Peak memory usage goes up a little for some cases, but down by more for
some other cases -- as much as 18% for non-incremental builds of
`packed-simd`.

The commit also:
- removes the `repr(packed)`, because it has negligible effect, but can
  cause undefined behaviour;
- replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.)
  with derived ones.
2019-04-05 12:26:09 +11:00
Mazdak Farrokhzad d31d80b7d4
Rollup merge of #59630 - nnethercote:shrink-mir-Statement, r=pnkfelix
Shrink `mir::Statement`.

The `InlineAsm` variant is extremely rare, and `mir::Statement` often
contributes significantly to peak memory usage.
2019-04-03 04:36:14 +02:00
Mazdak Farrokhzad a96e3883c1
Rollup merge of #59514 - tmandry:remove-adt-def-from-projection-elem, r=eddyb
Remove adt_def from projections and downcasts in MIR

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding `def_id`, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb
2019-04-03 04:36:12 +02:00
Nicholas Nethercote d00d639c54 Shrink `mir::Statement`.
The `InlineAsm` variant is extremely rare, and `mir::Statement` often
contributes significantly to peak memory usage.
2019-04-03 09:09:59 +11:00
Tyler Mandry ac29ca75e0 Replace adt_def with name in mir::ProjectionElem::Downcast 2019-04-02 12:02:17 -07:00
kenta7777 3c8caaca7d renames EvalErrorKind to InterpError 2019-04-02 01:02:18 +09:00
Taiki Endo 07021e07ed Allow closure to unsafe fn coercion 2019-04-01 00:00:43 +09:00
Mazdak Farrokhzad 90c2d641eb
Rollup merge of #59232 - saleemjaffer:mir_place_refactor, r=oli-obk
Merge `Promoted` and `Static` in `mir::Place`

fixes #53848
2019-03-26 09:05:40 +01:00
Vadim Petrochenkov 7f5a8dcdb9 Remove `VariantDef::parent_did` 2019-03-24 14:41:35 +03:00
David Wood 5c3d1e5d76 Separate variant id and variant constructor id.
This commit makes two changes - separating the `NodeId` that identifies
an enum variant from the `NodeId` that identifies the variant's
constructor; and no longer creating a `NodeId` for `Struct`-style enum
variants and structs.

Separation of the variant id and variant constructor id will allow the
rest of RFC 2008 to be implemented by lowering the visibility of the
variant's constructor without lowering the visbility of the variant
itself.

No longer creating a `NodeId` for `Struct`-style enum variants and
structs mostly simplifies logic as previously this `NodeId` wasn't used.
There were various cases where the `NodeId` wouldn't be used unless
there was an unit or tuple struct or enum variant but not all uses of
this `NodeId` had that condition, by removing this `NodeId`, this must
be explicitly dealt with. This change mostly applied cleanly, but there
were one or two cases in name resolution and one case in type check
where the existing logic required a id for `Struct`-style enum variants
and structs.
2019-03-24 12:10:16 +03:00
Saleem Jaffer 752544b284 adding mir::StaticKind enum for static and promoted 2019-03-23 20:18:52 +05:30
Saleem Jaffer 7fb1c22da1 promoted is still left in 2 places 2019-03-18 15:03:29 +05:30
Oliver Scherer 5cd2806621 Revert the `LazyConst` PR 2019-03-16 21:04:10 +01:00