Commit Graph

66 Commits

Author SHA1 Message Date
bohan 482275b194 use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Jason Newcomb f686bd8949 Take &mut Results in ResultsVisitor 2023-09-02 19:35:51 -04:00
Ralf Jung 4c53783f3c when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
Camille GILLOT 7ded3409b8 Specify that method only applies statement effects. 2023-08-16 18:12:18 +00:00
Camille GILLOT 388f6a6413 Make TerminatorEdge plural. 2023-08-16 18:12:18 +00:00
Camille GILLOT 6cf15d4cb5 Rename MaybeUnreachable. 2023-08-16 18:12:18 +00:00
Camille GILLOT 5173d85043 Allow apply_terminator_effect to customize edges. 2023-08-16 18:12:17 +00:00
Camille GILLOT 32711b2b4e Introduce MaybeUnreachable. 2023-08-16 18:12:17 +00:00
Camille GILLOT 934a99eb65 Move domain_size to GenKillAnalysis. 2023-08-16 18:12:17 +00:00
Camille GILLOT 760881b29d Create bottom on-the-fly instead of cloning it. 2023-08-16 18:12:17 +00:00
Florian Groult 3224ea4424 Export AnalysisResults trait in rustc_mir_dataflow 2023-06-27 11:35:32 +02:00
Michael Goulet 31d1fbf8d2 Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
Deadbeef 89c24af133 Better error for non const PartialEq call generated by match 2023-06-18 05:24:38 +00:00
Rémy Rakic 9395e2771a make mir dataflow graphviz dumps opt-in 2023-06-14 12:30:13 +00:00
bors 68c8fdaac0 Auto merge of #108293 - Jarcho:mut_analyses, r=eholk
Take MIR dataflow analyses by mutable reference

The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be `fn apply_deref(potential_targets: &mut Vec<Target>)` which would use the scratch space contained in the analysis to send arguments and receive the results.

The alternative to this would be to wrap everything in a `RefCell`, which is what `MaybeRequiresStorage` currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time.

For the implementation:
* `AnalysisResults` is an unfortunate requirement to avoid an unconstrained type parameter error.
* `CloneAnalysis` could just be `Clone` instead, but that would result in more work than is required to have multiple cursors over the same result set.
* `ResultsVisitor` now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary.
* `MaybeRequiresStorage` now no longer uses a `RefCell`, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.
2023-06-08 23:58:44 +00:00
Camille GILLOT 844c1cc5fe Remove DesugaringKind::Replace. 2023-05-25 17:40:46 +00:00
Jason Newcomb eaddc37075 Take MIR dataflow analyses by mutable reference. 2023-05-18 17:46:39 -04:00
Camille GILLOT 71138e9933 Make HasTop and HasBottom consts. 2023-05-09 17:27:58 +00:00
Maybe Waffle e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
DaniPopes 677357d32b Fix typos in compiler 2023-04-10 22:02:52 +02:00
Gary Guo e3f2edc75b Rename Abort terminator to Terminate
Unify terminology used in unwind action and terminator, and reflect
the fact that a nounwind panic is triggered instead of an immediate
abort is triggered for this terminator.
2023-04-06 09:34:16 +01:00
Gary Guo daeb844e0c Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
Yuki Okushi 4e0662c8a7 Rollup merge of #109847 - clubby789:graphviz-reachable, r=oli-obk
Only create graphviz nodes for reachable MIR bb's

Fixes #109832
2023-04-05 20:47:22 +09:00
clubby789 422c33030f Disable path trimming during graphviz output 2023-04-05 03:06:37 +01:00
clubby789 47ae42ee10 Only create graphviz nodes for reachable MIR bb's 2023-04-01 23:14:18 +01:00
Giacomo Pasini c5d4e4d907 Remove DropAndReplace terminator
PR 107844 made DropAndReplace unused, let's remove it completely
from the codebase.
2023-03-07 14:25:22 +01:00
Tomasz Miąsko 23e3840014 Remove dead unwinds before drop elaboration
As a part of drop elaboration, we identify dead unwinds, i.e., unwind
edges on a drop terminators which are known to be unreachable, because
there is no need to drop anything.

Previously, the data flow framework was informed about the dead unwinds,
and it assumed those edges are absent from MIR. Unfortunately, the data
flow framework wasn't consistent in maintaining this assumption.

In particular, if a block was reachable only through a dead unwind edge,
its state was propagated to other blocks still. This became an issue in
the context of change removes DropAndReplace terminator, since it
introduces initialization into cleanup blocks.

To avoid this issue, remove unreachable unwind edges before the drop
elaboration, and elaborate only blocks that remain reachable.
2023-02-23 14:05:03 +01: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
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
Oli Scherer 4f593ce5d8 Create format_args as late as possible 2022-12-01 08:49:51 +00: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 4f9c30fb67 Add initial version of value analysis and dataflow constant propagation 2022-11-07 10:35:08 +01: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
Tomasz Miąsko b48870b451 Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02: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
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
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 8c9a130056 Edit rustc_mir_dataflow::framework documentation 2022-07-06 11:20:40 -05: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
Maybe Waffle c1a2db3372 Move/rename lazy::Sync{OnceCell,Lazy} to sync::{Once,Lazy}Lock 2022-06-16 19:54:42 +04: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
Jakob Degen 09b0936db2 Refactor call terminator to always hold a destination place 2022-05-23 17:49:04 -04:00