Commit Graph

31 Commits

Author SHA1 Message Date
Gary Guo b044aaa905 Change InlineAsm to allow multiple targets instead 2024-02-24 18:50:09 +00:00
Nicholas Nethercote f312775e4f Remove unused arguments from ResultsVisitor::visit_block_{start,end}. 2023-12-08 07:55:17 +11:00
Nicholas Nethercote f450bf49c0 Use 'mir lifetime name more.
Some types have a `body: &'mir Body<'tcx>` and some have `body: &'a
Body<'tcx>`. The former is more readable, so this commit converts some
fo the latter to the former.
2023-11-23 18:49:58 +11:00
Nilstrieb 21a870515b Fix clippy::needless_borrow in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01: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 5173d85043 Allow apply_terminator_effect to customize edges. 2023-08-16 18:12:17 +00:00
Deadbeef 89c24af133 Better error for non const PartialEq call generated by match 2023-06-18 05:24:38 +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
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
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
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
Jakob Degen 9fb8da8f8f Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
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 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
Michael Goulet 1784634a39 Lifetime variance fixes for rustc 2022-05-22 14:29:32 -07:00
Tomasz Miąsko 2be012a0c6 Use sparse representation of switch sources
to avoid quadratic space overhead
2022-05-08 23:48:23 +02:00
Tomasz Miąsko fbc3cc18be Avoid constructing switch sources unless necessary
Switch sources are used by backward analysis with a custom switch int
edge effects, but are otherwise unnecessarily computed.

Delay the computation until we know that switch sources are indeed
required and avoid the computation otherwise.
2022-05-08 23:14:56 +02:00
Dylan MacKenzie 241ec5b3b3 Nit 2022-03-27 10:58:55 -07:00
Samuel E. Moelius III 37ebd47ddb Address review comments
* Add lazily computed `switch_sources` data structure
* Don't assume a target has only one associated value
2022-03-26 08:01:51 -04:00
Samuel E. Moelius III ee7413b94c Implement apply_switch_int_edge_effects for backward analyses 2022-03-24 20:08:45 -04:00
LegionMammal978 fed881aafc Remove in_band_lifetimes from rustc_mir_dataflow
See #91867 for more information.
2021-12-16 14:29:43 -05:00
Amanieu d'Antras 940b2eabad Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
Camille GILLOT fd9c04fe32 Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00