Commit Graph

70 Commits

Author SHA1 Message Date
Markus Westerlind
33513fad80 Avoid an intermediate Vec in mir simplify 2020-02-13 11:13:13 +01:00
Markus Westerlind
dec8166abc Use Vec::append 2020-02-13 11:13:13 +01:00
Markus Westerlind
851a701f90 Reuse a Vec in mir simplification 2020-02-13 11:13:13 +01:00
Santiago Pastorino
5d9b399044 Remove PlaceBase enum and make Place base field be local: Local 2020-01-10 09:08:25 +01:00
Santiago Pastorino
fd5aa32c35 Remove Static from PlaceBase 2020-01-10 09:08:24 +01:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Yuki Okushi
a7f930748c
Rollup merge of #67134 - oli-obk:const_prop_zst, r=wesleywiser
Ensure that we get a hard error on generic ZST constants if their bod…

…y causes an error during evaluation

cc #67083 (does not fix because we still need the beta backport)

r? @wesleywiser

cc @RalfJung
2019-12-11 04:32:57 +09:00
Oliver Scherer
df26968bb5 Ensure that we get a hard error on generic ZST constants if their body causes an error during evaluation 2019-12-08 01:55:14 +01:00
Paul Daniel Faria
756aa1e46c rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded Index impl, remove body fn
rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence
rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-05 22:58:41 -05:00
Paul Daniel Faria
b2fe254c98 Remove HasLocalDecls impl from BodyCache's, properly reborrow to Body, rename all body_cache back to body 2019-12-02 08:40:56 -05:00
Paul Daniel Faria
595d161d36 Remove BodyCache.body and rely on Deref as much as possible for ReadOnlyBodyCache 2019-12-02 08:38:16 -05:00
Paul Daniel Faria
67b7a78231 Fix tidy errors 2019-12-02 08:38:16 -05:00
Paul Daniel Faria
4de31b26d1 Fix remaining compilation issues 2019-12-02 08:37:04 -05:00
Paul Daniel Faria
fc6b58d0a8 Simplify BodyCache impl and fix all remaining type errors in librustc_mir (lifetime errors still exist) 2019-12-02 08:35:08 -05:00
Paul Daniel Faria
52cc85f008 Address nits and remove unneeded pass 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
ad734680af Move predecessors cache invalidation back to basic_blocks_mut, add a couple more ensure_predecessors to prevent panics 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
570e4182e8 Address linting errors caught by CI 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
f534d9f8c4 Stop invalidating predecessors cache when accessing unique basic block, invalidate cache when accessing unique terminator 2019-12-02 08:30:30 -05:00
Eduard-Mihai Burtescu
563ed27c01 rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
Wesley Wiser
4505ff4bad [mir-opt] Handle aggregates in SimplifyLocals pass 2019-11-08 22:28:53 -05:00
Santiago Pastorino
d32c2865d6
Intern place projection 2019-10-22 10:33:36 -03:00
Wesley Wiser
2ec73395b9 Improve SimplifyLocals pass so it can remove unused consts
The `ConstProp` can cause many locals to be initialized to a constant
value and then never read from. `ConstProp` can also evaluate ZSTs into
constant values. Previously, many of these would be removed by other
parts of the MIR optimization pipeline. However, evaluating ZSTs
(especially `()`) into constant values defeated those parts of the
optimizer and so in a2e3ed5c05, I added a
hack to `ConstProp` that skips evaluating ZSTs to avoid that regression.

This commit changes `SimplifyLocals` so that it doesn't consider writes
of const values to a local to be a use of that local. In doing so,
`SimplifyLocals` is able to remove otherwise unused locals left behind
by other optimization passes (`ConstProp` in particular).
2019-10-20 23:49:42 -04:00
Santiago Pastorino
48349960e6
Use Cow to handle modifications of projection in preparation for interning 2019-10-18 10:06:13 -04:00
Santiago Pastorino
d53fc9cae5
Add process_* place hooks to improve code reutilization 2019-10-17 22:06:56 -04:00
Santiago Pastorino
591cc9aede
Prepare simplify MutVisitor to have projections interned 2019-10-17 22:06:55 -04:00
csmoe
64f61c7888 remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00
csmoe
d20183dbbf remove bit_set re-export from rustc_data_structures 2019-09-29 16:11:30 +00:00
Wesley Wiser
666180c324 Move 'tcx lifetime on MirPass 2019-08-22 06:36:30 -04:00
Jeremy Stucki
0477e07272
Remove needless lifetimes 2019-07-03 10:00:26 +02:00
Eduard-Mihai Burtescu
b25b466a88 rustc: remove 'x: 'y bounds (except from comments/strings). 2019-06-18 18:10:21 +03:00
Eduard-Mihai Burtescu
afc39bbf24 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-14 18:58:32 +03:00
Eduard-Mihai Burtescu
f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu
17cdd356da rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
2441253508 Fix fallout from deny(unused_lifetimes). 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
37799a5552 rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
d110d309b6 rustc_mir: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Jad Ghalayini
80ff07f30d Changed usages of mir in librustc::mir and librustc_mir to body 2019-06-09 16:05:05 -04: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
Matthew Jasper
22226fa7fb Remove region from borrow place contexts 2019-04-26 21:35:10 +01:00
Ralf Jung
544b3a1bb4 fix rebase fallout 2019-02-09 12:19:04 +01:00
Taiki Endo
725af30809 librustc_mir => 2018 2019-02-08 06:28:15 +09:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Shotaro Yamada
83298a2120 Make SimplifyCfg collapse goto chains from bb0 2018-12-13 12:01:15 +09:00
kennytm
9d9146ad95
Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco
refactor: use shorthand fields

refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07 21:27:00 +08:00
teresy
eca11b99a7 refactor: use shorthand fields 2018-11-06 15:05:44 -05:00
David Wood
6208bd8e03
Refactor and add PlaceContext::AscribeUserTy.
This commit refactors `PlaceContext` to split it into four different
smaller enums based on if the context represents a mutating use,
non-mutating use, maybe-mutating use or a non-use (this is based on the
recommendation from @oli-obk on Zulip[1]).

This commit then introduces a `PlaceContext::AscribeUserTy` variant.
`StatementKind::AscribeUserTy` is now correctly mapped to
`PlaceContext::AscribeUserTy` instead of `PlaceContext::Validate`.
`PlaceContext::AscribeUserTy` can also now be correctly categorized as a
non-use which fixes an issue with constant promotion in statics after a
cast introduces a `AscribeUserTy` statement.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/subject/.2355288.20cast.20fails.20to.20promote.20to.20'static/near/136536949
2018-10-27 12:11:37 +02:00
Nicholas Nethercote
266e2d3d69 Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.
Currently we have two files implementing bitsets (and 2D bit matrices).
This commit combines them into one, taking the best features from each.

This involves renaming a lot of things. The high level changes are as
follows.
- bitvec.rs              --> bit_set.rs
- indexed_set.rs         --> (removed)
- BitArray + IdxSet      --> BitSet (merged, see below)
- BitVector              --> GrowableBitSet
- {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet
- BitMatrix              --> BitMatrix
- SparseBitMatrix        --> SparseBitMatrix

The changes within the bitset types themselves are as follows.

```
OLD             OLD             NEW
BitArray<C>     IdxSet<T>       BitSet<T>
--------        ------          ------
grow            -               grow
new             -               (remove)
new_empty       new_empty       new_empty
new_filled      new_filled      new_filled
-               to_hybrid       to_hybrid
clear           clear           clear
set_up_to       set_up_to       set_up_to
clear_above     -               clear_above
count           -               count
contains(T)     contains(&T)    contains(T)
contains_all    -               superset
is_empty        -               is_empty
insert(T)       add(&T)         insert(T)
insert_all      -               insert_all()
remove(T)       remove(&T)      remove(T)
words           words           words
words_mut       words_mut       words_mut
-               overwrite       overwrite
merge           union           union
-               subtract        subtract
-               intersect       intersect
iter            iter            iter
```

In general, when choosing names I went with:
- names that are more obvious (e.g. `BitSet` over `IdxSet`).
- names that are more like the Rust libraries (e.g. `T` over `C`,
  `insert` over `add`);
- names that are more set-like (e.g. `union` over `merge`, `superset`
  over `contains_all`, `domain_size` over `num_bits`).

Also, using `T` for index arguments seems more sensible than `&T` --
even though the latter is standard in Rust collection types -- because
indices are always copyable. It also results in fewer `&` and `*`
sigils in practice.
2018-09-18 07:08:09 +10:00
Mark Rousskov
2bc71971e5 Normalize DebugInfoLevel to standard style 2018-08-04 06:54:34 -06:00
Mark Rousskov
9bc4fbb10a Split out growth functionality into BitVector type 2018-08-01 06:50:40 -06:00