Commit Graph

217 Commits

Author SHA1 Message Date
Jannis Christopher Köhl
630e17d3e4 Limit number of tracked places, and some other perf improvements 2022-11-07 10:35:26 +01:00
Jannis Christopher Köhl
1f82a9f89e Move HasTop and HasBottom into lattice.rs 2022-11-07 10:35:25 +01:00
Jannis Christopher Köhl
de69d088a4 Explicitly match all terminators 2022-11-07 10:35:24 +01:00
Jannis Christopher Köhl
5b7b309c60 Improve documentation of assumptions 2022-11-07 10:35:24 +01:00
Jannis Christopher Köhl
274a49132b Improve documentation, plus some small changes 2022-11-07 10:35:23 +01:00
Jannis Christopher Köhl
aaa35b3e48 Add comment for the current retag situation 2022-11-07 10:35:22 +01:00
Jannis Christopher Köhl
3c0f3b04b5 Only assume Stacked Borrows if -Zunsound-mir-opts is given 2022-11-07 10:35:21 +01:00
Jannis Christopher Köhl
111324e17c Prevent registration inside references if target is !Freeze 2022-11-07 10:35:20 +01:00
Jannis Christopher Köhl
4478a87018 Fix formatting 2022-11-07 10:35:20 +01:00
Jannis Christopher Köhl
7ab1ba95de Remove Unknown state in favor of Value(Top) 2022-11-07 10:35:20 +01:00
Jannis Christopher Köhl
1765587846 Only track (trivially) freeze types 2022-11-07 10:35:20 +01:00
Jannis Christopher Köhl
b5063ab0e5 Make more assumptions explicit 2022-11-07 10:35:19 +01:00
Jannis Christopher Köhl
2f66e9417f Flood with bottom for Deinit, StorageLive and StorageDead 2022-11-07 10:35:19 +01:00
Jannis Christopher Köhl
eab77320e6 Handle NonDivergingIntrinsic and CopyNonOverlapping 2022-11-07 10:35:19 +01:00
Jannis Christopher Köhl
f99950f6ae Update test results after rebase 2022-11-07 10:35:18 +01:00
Jannis Christopher Köhl
c56e99cdba Fix typo 2022-11-07 10:35:18 +01:00
Jannis Christopher Köhl
13b70599c1 Only allow registration of scalars for now 2022-11-07 10:35:16 +01:00
Jannis Christopher Köhl
817c27744d Handle StorageLive 2022-11-07 10:35:16 +01:00
Jannis Christopher Köhl
e2ddf8a6e5 Add comment about downcast projection element 2022-11-07 10:35:15 +01:00
Jannis Christopher Köhl
1e5ca57014 Use StorageDead and Deinit to flood place 2022-11-07 10:35:15 +01:00
Jannis Christopher Köhl
904adcac0f Flood place on drop 2022-11-07 10:35:15 +01:00
Jannis Christopher Köhl
2113e45488 Remove superfluous line 2022-11-07 10:35:14 +01:00
Jannis Christopher Köhl
2e4d0820d2 Add more documentation 2022-11-07 10:35:14 +01:00
Jannis Christopher Köhl
fe84bbf844 Add tracking of unreachability 2022-11-07 10:35:13 +01:00
Jannis Christopher Köhl
16dedba1c8 Ignore terminators explicitly 2022-11-07 10:35:13 +01:00
Jannis Christopher Köhl
8a789ce009 Reject registration of downcasts for now 2022-11-07 10:35:12 +01:00
Jannis Christopher Köhl
ad99d2e15d Move handling of references and simplify flooding 2022-11-07 10:35:11 +01:00
Jannis Christopher Köhl
3f98dc7838 Clarify place expressions vs place objects 2022-11-07 10:35:11 +01:00
Jannis Christopher Köhl
e75ad93d95 Begin a semi-formal argument for correctness 2022-11-07 10:35:10 +01:00
Jannis Christopher Köhl
292869493c Add additional flooding when assigning a value and corresponding test 2022-11-07 10:35:10 +01:00
Jannis Christopher Köhl
bb1639769e Clarify registration and tracking of references 2022-11-07 10:35:10 +01:00
Jannis Christopher Köhl
56ff16d19f Fix spelling 2022-11-07 10:35:09 +01:00
Jannis Christopher Köhl
d0afe6833d Try field type normalization instead of forcing it 2022-11-07 10:35:08 +01:00
Jannis Christopher Köhl
4f9c30fb67 Add initial version of value analysis and dataflow constant propagation 2022-11-07 10:35:08 +01:00
Oli Scherer
44d1936d00 Some tracing and comment cleanups 2022-11-04 17:10:07 +00:00
Nilstrieb
c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
Matthias Krüger
c731646d6a
Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Remove `mir::CastKind::Misc`

As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.

r? ````@oli-obk````
2022-10-08 14:38:18 +02:00
ouz-a
d59c7ff000 Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
reez12g
9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Jhonny Bill Mena
a3396b2070 UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
Jhonny Bill Mena
19b348fed4 UPDATE - rename DiagnosticHandler trait to IntoDiagnostic 2022-09-21 11:39:52 -04:00
bors
4136b59b7d Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
Oli Scherer
dab1074b91 Only generate OpaqueCast for opaque types 2022-09-16 11:37:50 +00:00
Oli Scherer
40e2de8c41 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
Oli Scherer
b7413511dc Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
3f07645120 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
Matthias Krüger
d182081de1
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Michael Goulet
93b2acd88a
Rollup merge of #100744 - 5225225:migrate-rustc-mir-dataflow, r=davidtwco
Migrate rustc_mir_dataflow to diagnostic structs
2022-08-26 15:56:24 -07:00
Tomasz Miąsko
b48870b451 Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Tomasz Miąsko
58eabb291d Add method that applies DefUse effect 2022-08-25 10:38:00 +02:00
Tomasz Miąsko
31d892a942 Fix liveness analysis for yield terminators
A resume place is evaluated and assigned to only after a yield
terminator resumes. Ensure that locals used when evaluating the
resume place are live across the yield.
2022-08-25 07:12:16 +02:00
5225225
f20cc9ae4e Rename rustc_mir_dataflow diagnostic to mir_dataflow 2022-08-23 13:48:15 +01:00
5225225
ee2b16100e Migrate rustc_mir_dataflow to diagnostic structs 2022-08-23 11:24:51 +01:00
SparrowLii
d39fefdd69 use type alias impl trait in outlives_bounds::InferCtxtExt 2022-08-22 18:10:28 +08:00
Tomasz Miąsko
099a32bbe4 Remove redundant TransferWrapper struct 2022-08-01 17:08:19 +02:00
bors
7dfdd64433 Auto merge of #99667 - ouz-a:some_branch, r=oli-obk
Optimize `UnDerefer`

Addresses the performance [issues](https://github.com/rust-lang/rust/pull/98145#issuecomment-1183548597) faced here.

r? `@oli-obk`
2022-07-29 07:11:50 +00:00
ouz-a
bd24b4006c type alias covers whole return 2022-07-28 13:52:49 +03:00
ouz-a
bd52f58e3b create type alias 2022-07-28 12:56:57 +03:00
ouz-a
a5c895e1d8 remove clone 2022-07-25 17:08:54 +03:00
ouz-a
4e726e04cd fix import error 2022-07-24 14:57:49 +03:00
ouz-a
09134982e5 optimize un_derefer 2022-07-24 14:40:43 +03:00
bors
be9cfb307e Auto merge of #99058 - michaelwoerister:remove-stable-set-and-map, r=nagisa
Remove the unused StableSet and StableMap types from rustc_data_structures.

The current implementation is not "stable" in the same sense that `HashStable` and `StableHasher` are stable, i.e. across compilation sessions. So, in my opinion, it's better to remove those types (which are basically unused anyway) than to give the wrong impression that these are safe for incr. comp.

I plan to provide new "stable" collection types soon that can be used to replace `FxHashMap` and `FxHashSet` in query results (see [draft](69d03ac7a7)). It's unsound that `HashMap` and `HashSet` implement `HashStable` (see https://github.com/rust-lang/rust/issues/98890 for a recent P-critical bug caused by this) -- so we should make some progress there.
2022-07-20 22:19:30 +00:00
Michael Woerister
88f6c6d8a0 Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
Oli Scherer
4a742a691e Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"
This reverts commit 6f8fb911ad, reversing
changes made to 7210e46dc6.
2022-07-20 07:55:58 +00:00
Matthias Krüger
6f8fb911ad
Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank
Allow destructuring opaque types in their defining scopes

fixes #96572

Before this PR, the following code snippet failed with an incomprehensible error, and similar code just ICEd in mir borrowck.

```rust
    type T = impl Copy;
    let foo: T = (1u32, 2u32);
    let (a, b) = foo;
```

The problem was that the last line created MIR projections of the form `foo.0` and `foo.1`, but `foo`'s type is `T`, which doesn't have fields (only its hidden type does). But the pattern supplies enough type information (a tuple of two different inference types) to bind a hidden type.
2022-07-16 22:30:47 +02:00
Oli Scherer
84a444a1f4 Introduce opaque type to hidden type projection 2022-07-15 15:49:22 +00:00
pierwill
0d45977aa5 Remove FIXME from MIR always_storage_live_locals 2022-07-14 15:30:36 -05:00
Joshua Nelson
3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
ouz-a
cb0017f2f8 add new rval, pull deref early 2022-07-12 14:26:41 +03:00
Matthias Krüger
416dc43124
Rollup merge of #99022 - pierwill:always-storage-live-locals, r=pierwill
MIR dataflow: Rename function to `always_storage_live_locals`

Related to #99021.

r?  ```@JakobDegen``` (as discussed on Zulip)
2022-07-09 12:52:50 +02:00
pierwill
8a1c1ec8b2 MIR dataflow: Rename function to always_storage_live_locals
Related to #99021.
2022-07-07 13:49:40 -05:00
Matthias Krüger
b4f8537a56
Rollup merge of #98986 - pierwill:patch-5, r=oli-obk
Fix missing word in comment
2022-07-07 20:33:27 +02:00
Dylan DPC
6910d84bc4
Rollup merge of #98981 - pierwill:pierwill/dataflow-docs-edits, r=Dylan-DPC
Edit `rustc_mir_dataflow::framework` documentation

Some edits for clarity and consistency.
2022-07-07 18:06:55 +05:30
Tomasz Miąsko
dfa6a7cbde Move switch_sources from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
Tomasz Miąsko
39d9c1cb1f Move predecessors from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
Tomasz Miąsko
2446b17745 Move is_cfg_cyclic from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
pierwill
deaa92b34b
Fix missing word in comment 2022-07-06 13:26:26 -05:00
pierwill
8c9a130056 Edit rustc_mir_dataflow::framework documentation 2022-07-06 11:20:40 -05:00
Guillaume Gomez
5d650bb92e
Rollup merge of #98944 - pierwill:flatset-docs, r=Dylan-DPC
Edit `rustc_mir_dataflow::framework::lattice::FlatSet` docs

Cosmetic improvements. Adds a paragraph break, and
ellipses to signify arbitrary size of a flat set.
2022-07-05 23:43:33 +02:00
pierwill
f8b16c5d87 Edit rustc_mir_dataflow::framework::lattice::FlatSet docs
Cosmetic improvements. Adds a paragraph break, and
ellipses to signify arbitrary size of a flat set.
2022-07-05 11:34:39 -05:00
lcnr
cf9c0a5935 cleanup mir visitor for rustc::pass_by_value 2022-07-01 16:21:21 +02:00
Nicholas Nethercote
7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
bors
a25b1315ee Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obk
Remove dereferencing of Box from codegen

Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains.

Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-21 11:00:39 +00:00
Matthias Krüger
f351f347b8
Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-se
once cell renamings

This PR does the renamings proposed in https://github.com/rust-lang/rust/issues/74465#issuecomment-1153703128

- Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}`
- Move/rename `lazy::{SyncOnceCell, SyncLazy}` to `sync::{OnceLock, LazyLock}`

(I used `Lazy...` instead of `...Lazy` as it seems to be more consistent, easier to pronounce, etc)

```@rustbot``` label +T-libs-api -T-libs
2022-06-19 00:17:13 +02:00
bors
ecdd374e61 Auto merge of #97863 - JakobDegen:bitset-choice, r=nnethercote
`BitSet` related perf improvements

This commit makes two changes:
 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet`
 2. Overrides the `fold` method for the iterator for `ChunkedBitSet`

I have local benchmarks verifying that each of these changes individually yield significant perf improvements to #96451 . I'm hoping this will be true outside of that context too. If that is not the case, I'll try to gate things on where they help as needed

r? `@nnethercote` who I believe was working on closely related things, cc `@tmiasko` because of the destprop pr
2022-06-17 07:35:22 +00:00
Maybe Waffle
c1a2db3372 Move/rename lazy::Sync{OnceCell,Lazy} to sync::{Once,Lazy}Lock 2022-06-16 19:54:42 +04:00
DrMeepster
cb417881a9 remove box derefs from codgen 2022-06-15 18:38:26 -07:00
Yuki Okushi
bb4805118a
Rollup merge of #98067 - klensy:compiler-deps2, r=Dylan-DPC
compiler: remove unused deps

Removed unused dependencies in compiler crates and moves few `libc` under `target.cfg(unix)` .
2022-06-15 12:02:02 +09:00
Jakob Degen
bc7cd2f351 BitSet perf improvements
This commit makes two changes:
 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet`
 2. Overrides the `fold` method for the iterator for `ChunkedBitSet`
2022-06-14 19:41:58 -07:00
b-naber
705d818bd5 implement valtrees as the type-system representation for constant values 2022-06-14 16:07:11 +02:00
klensy
4ea4e2e76d remove currently unused deps 2022-06-13 22:20:51 +03:00
Tomasz Miąsko
777bf84f6c Merge arms in borrowed locals transfer function 2022-06-12 07:27:57 +02:00
Tomasz Miąsko
915f091819 Remove duplicated implementations of borrowed locals analysis 2022-06-12 07:27:57 +02:00
Dylan DPC
d380b457d8
Rollup merge of #97597 - tmiasko:simplify-locals-side-effects, r=RalfJung,JakobDegen
Preserve unused pointer to address casts

Fixes #97421.

cc `@RalfJung`
2022-06-08 07:37:30 +02:00
Matthias Krüger
796c466cea
Rollup merge of #97832 - tmiasko:const-direction, r=cjgillot
Change `Direction::{is_forward,is_backward}` functions into constants

Make it explicit that the analysis direction is constant.

This also makes the value immediately available for optimizations.
Previously those functions were neither inline nor generic and so their
definition was unavailable when using data flow framework from other
crates.
2022-06-07 23:55:27 +02:00
Tomasz Miąsko
6277c3a944 Preserve unused pointer to address casts 2022-06-07 17:33:16 +02:00
Tomasz Miąsko
39de03d844 Change Direction::{is_forward,is_backward} functions into constants
Make it explicit that the analysis direction is constant.

This also makes the value immediately available for optimizations.
Previously those functions were neither inline nor generic and so their
definition was unavailable when using data flow framework from other
crates.
2022-06-07 17:02:55 +02:00
Tomasz Miąsko
631d767fee Remove AlwaysLiveLocals wrapper struct
It is just a wrapper around a `BitSet` and
doesn't have any functionality of its own.
2022-06-07 16:54:00 +02:00