Commit Graph

257 Commits

Author SHA1 Message Date
Camille GILLOT
c48756cdbf Limit creation of tracked place directly. 2023-02-06 21:55:05 +00:00
Camille GILLOT
9a6c04f5d0 Handle discriminants in dataflow-const-prop. 2023-02-06 21:51:47 +00:00
Camille GILLOT
cd3649b2a5 Only exclude locals if the place is not indirect. 2023-02-06 21:51:45 +00:00
Camille GILLOT
0d59b8c997 Remove redundant test. 2023-02-06 21:29:02 +00:00
Matthias Krüger
7be6e6d954
Rollup merge of #107724 - klensy:imports, r=Mark-Simulacrum
remove unused rustc_* imports
2023-02-06 21:16:42 +01:00
klensy
4f5f9f0a13 remove unused imports 2023-02-06 17:40:18 +03:00
Camille GILLOT
8e05ab04e5 Run SROA to fixpoint. 2023-02-05 12:08:42 +00:00
Camille GILLOT
42c9514629 Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
Giacomo Pasini
68c1e2fd48
Treat Drop as a rmw operation
Previously, a Drop terminator was considered a move in MIR.
This commit changes the behavior to only treat Drop as a mutable
access to the dropped place.

In order for this change to be correct, we need to guarantee that
  a) A dropped value won't be used again
  b) Places that appear in a drop won't be used again before a
     subsequent initialization.

We can ensure this to be correct at MIR construction because Drop
will only be emitted when a variable goes out of scope,
thus having:
  (a) as there is no way of reaching the old value. drop-elaboration
     will also remove any uninitialized drop.
  (b) as the place can't be named following the end of the scope.

However, the initialization status, previously tracked by moves,
should also be tied to the execution of a Drop, hence the
additional logic in the dataflow analyses.
2023-01-30 00:20:40 +01:00
Bryan Garza
360db516cc Create stable metric to measure long computation in Const Eval
This patch adds a `MirPass` that tracks the number of back-edges and
function calls in the CFG, adds a new MIR instruction to increment a
counter every time they are encountered during Const Eval, and emit a
warning if a configured limit is breached.
2023-01-23 23:56:22 +00:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
nils
fd7a159710 Fix uninlined_format_args for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Tomasz Miąsko
357c3cf72c Fix handling of dead unwinds in backward analyses
Dead unwinds set contains a head of an unreachable unwind edge.
2023-01-02 22:24:01 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
bors
eb9e5e711d Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
Improve syntax of `newtype_index`

This makes it more like proper Rust and also makes the implementation a lot simpler.

Mostly just turns weird flags in the body into proper attributes.

It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-20 07:27:01 +00:00
Rémy Rakic
8275d115fb Revert "Auto merge of #103880 - b-naber:field-ty-mir, r=lcnr"
This reverts commit 03770f0e2b, reversing
changes made to 01ef4b21dc.
2022-12-19 15:31:20 +00:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Nilstrieb
d679764fb6 Make #[debug_format] an attribute in newtype_index
This removes the `custom` format functionality as its only user was
trivially migrated to using a normal format.

If a new use case for a custom formatting impl pops up, you can add it
back.
2022-12-18 21:37:38 +01:00
bors
03770f0e2b Auto merge of #103880 - b-naber:field-ty-mir, r=lcnr
Use non-ascribed type as field's type in mir

Fixes https://github.com/rust-lang/rust/issues/96514

r? `@lcnr`
2022-12-16 12:47:49 +00:00
Oli Scherer
4ffe3bdf99 Remove one more usage of mk_substs_trait 2022-12-14 15:36:39 +00:00
Jakob Degen
3522d48112 Don't require owned data in MaybeStorageLive 2022-12-13 04:22:47 -08:00
bors
71ec1457ee Auto merge of #105436 - nnethercote:inline-place_contents_drop_state_cannot_differ, r=spastorino
Inline and remove `place_contents_drop_state_cannot_differ`.

It has a single call site and is hot enough to be worth inlining. And make sure `is_terminal_path` is inlined, too.

r? `@ghost`
2022-12-13 03:28:57 +00:00
Matthias Krüger
2daa3bcbc2
Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-dead
compiler: remove unnecessary imports and qualified paths

Some of these imports were necessary before Edition 2021, others were already in the prelude.

I hope it's fine that this PR is so spread-out across files :/
2022-12-11 09:51:57 +01:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Jakob Degen
9fb8da8f8f Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
Nicholas Nethercote
68a19209e0 Inline and remove place_contents_drop_state_cannot_differ.
It has a single call site and is hot enough to be worth inlining. And
make sure `is_terminal_path` is inlined, too.
2022-12-08 13:59:29 +11:00
Rageking8
58110572fb fix dupe word typos 2022-12-05 16:42:36 +08:00
Oli Scherer
4f593ce5d8 Create format_args as late as possible 2022-12-01 08:49:51 +00:00
Jakob Degen
245c60749a Rewrite dest prop.
This fixes a number of correctness issues from the previous version. Additionally, we use a new
strategy which has much better performance charactersitics and also finds more opportunities to
apply the optimization.
2022-11-26 18:04:54 -08:00
b-naber
9061ffba8c use no type in ProjectionElem::Field for PlaceBuilder::UpVar 2022-11-23 21:25:27 +01:00
Oli Scherer
ec8d01fdcc Allow iterators instead of requiring slices that will get turned into iterators 2022-11-21 20:33:55 +00:00
Matthias Krüger
e3036df003 couple of clippy::perf fixes 2022-11-18 10:30:47 +01:00
Jannis Christopher Köhl
108790b8dc Remove log statement that was commented out 2022-11-12 20:32:09 +01:00
Jannis Christopher Köhl
2e034dc68c Exclude locals completely, instead of individual places 2022-11-12 14:57:14 +01:00
Jannis Christopher Köhl
3c6d1a723d Add test for repr(transparent) with scalar 2022-11-11 11:24:31 +01:00
Jannis Christopher Köhl
8ecb276735 Simplify creation of map 2022-11-10 19:12:10 +01:00
Jannis Christopher Köhl
9766ee0b20 Fix struct field tracking and add tests for it 2022-11-09 18:21:42 +01:00
Jannis Christopher Köhl
bfbca6c75c Completely remove tracking of references for now 2022-11-09 18:03:30 +01:00
Jannis Christopher Köhl
3997893ccb Fix rebase 2022-11-07 11:01:44 +01:00
Jannis Christopher Köhl
89f934917d Small corrections of documentation 2022-11-07 10:35:26 +01:00
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