Skip to content

Commit 2055237

Browse files
authoredOct 30, 2024
Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercote
Remove `Engine` It's just unnecessary plumbing. Removing it results in less code, and simpler code. r? ``@cjgillot``
2 parents 2480e3b + d78e7bb commit 2055237

File tree

15 files changed

+139
-205
lines changed

15 files changed

+139
-205
lines changed
 

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ fn do_mir_borrowck<'tcx>(
193193
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, |_| true)));
194194

195195
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
196-
.into_engine(tcx, body)
197-
.pass_name("borrowck")
198-
.iterate_to_fixpoint()
196+
.iterate_to_fixpoint(tcx, body, Some("borrowck"))
199197
.into_results_cursor(body);
200198

201199
let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(def).is_fn_or_closure();
@@ -243,18 +241,21 @@ fn do_mir_borrowck<'tcx>(
243241
// usage significantly on some benchmarks.
244242
drop(flow_inits);
245243

246-
let flow_borrows = Borrows::new(tcx, body, &regioncx, &borrow_set)
247-
.into_engine(tcx, body)
248-
.pass_name("borrowck")
249-
.iterate_to_fixpoint();
250-
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &move_data)
251-
.into_engine(tcx, body)
252-
.pass_name("borrowck")
253-
.iterate_to_fixpoint();
254-
let flow_ever_inits = EverInitializedPlaces::new(body, &move_data)
255-
.into_engine(tcx, body)
256-
.pass_name("borrowck")
257-
.iterate_to_fixpoint();
244+
let flow_borrows = Borrows::new(tcx, body, &regioncx, &borrow_set).iterate_to_fixpoint(
245+
tcx,
246+
body,
247+
Some("borrowck"),
248+
);
249+
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &move_data).iterate_to_fixpoint(
250+
tcx,
251+
body,
252+
Some("borrowck"),
253+
);
254+
let flow_ever_inits = EverInitializedPlaces::new(body, &move_data).iterate_to_fixpoint(
255+
tcx,
256+
body,
257+
Some("borrowck"),
258+
);
258259

259260
let movable_coroutine =
260261
// The first argument is the coroutine type passed by value

‎compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
6464
let ConstCx { tcx, body, .. } = *ccx;
6565

6666
FlowSensitiveAnalysis::new(NeedsDrop, ccx)
67-
.into_engine(tcx, body)
68-
.iterate_to_fixpoint()
67+
.iterate_to_fixpoint(tcx, body, None)
6968
.into_results_cursor(body)
7069
});
7170

@@ -94,8 +93,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
9493
let ConstCx { tcx, body, .. } = *ccx;
9594

9695
FlowSensitiveAnalysis::new(NeedsNonConstDrop, ccx)
97-
.into_engine(tcx, body)
98-
.iterate_to_fixpoint()
96+
.iterate_to_fixpoint(tcx, body, None)
9997
.into_results_cursor(body)
10098
});
10199

@@ -124,8 +122,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
124122
let ConstCx { tcx, body, .. } = *ccx;
125123

126124
FlowSensitiveAnalysis::new(HasMutInterior, ccx)
127-
.into_engine(tcx, body)
128-
.iterate_to_fixpoint()
125+
.iterate_to_fixpoint(tcx, body, None)
129126
.into_results_cursor(body)
130127
});
131128

@@ -240,8 +237,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
240237
let always_live_locals = &always_storage_live_locals(&ccx.body);
241238
let mut maybe_storage_live =
242239
MaybeStorageLive::new(Cow::Borrowed(always_live_locals))
243-
.into_engine(ccx.tcx, &ccx.body)
244-
.iterate_to_fixpoint()
240+
.iterate_to_fixpoint(ccx.tcx, &ccx.body, None)
245241
.into_results_cursor(&ccx.body);
246242

247243
// And then check all `Return` in the MIR, and if a local is "maybe live" at a

‎compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
//!
88
//! The `impls` module contains several examples of dataflow analyses.
99
//!
10-
//! Create an `Engine` for your analysis using the `into_engine` method on the `Analysis` trait,
11-
//! then call `iterate_to_fixpoint`. From there, you can use a `ResultsCursor` to inspect the
12-
//! fixpoint solution to your dataflow problem, or implement the `ResultsVisitor` interface and use
13-
//! `visit_results`. The following example uses the `ResultsCursor` approach.
10+
//! Then call `iterate_to_fixpoint` on your type that impls `Analysis` to get a `Results`. From
11+
//! there, you can use a `ResultsCursor` to inspect the fixpoint solution to your dataflow problem,
12+
//! or implement the `ResultsVisitor` interface and use `visit_results`. The following example uses
13+
//! the `ResultsCursor` approach.
1414
//!
1515
//! ```ignore (cross-crate-imports)
16-
//! use rustc_const_eval::dataflow::Analysis; // Makes `into_engine` available.
16+
//! use rustc_const_eval::dataflow::Analysis; // Makes `iterate_to_fixpoint` available.
1717
//!
1818
//! fn do_my_analysis(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
1919
//! let analysis = MyAnalysis::new()
20-
//! .into_engine(tcx, body)
21-
//! .iterate_to_fixpoint()
20+
//! .iterate_to_fixpoint(tcx, body, None)
2221
//! .into_results_cursor(body);
2322
//!
2423
//! // Print the dataflow state *after* each statement in the start block.
@@ -34,23 +33,29 @@
3433
3534
use std::cmp::Ordering;
3635

37-
use rustc_index::Idx;
36+
use rustc_data_structures::work_queue::WorkQueue;
3837
use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet};
39-
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges};
38+
use rustc_index::{Idx, IndexVec};
39+
use rustc_middle::bug;
40+
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges, traversal};
4041
use rustc_middle::ty::TyCtxt;
42+
use tracing::error;
43+
44+
use self::results::write_graphviz_results;
45+
use super::fmt::DebugWithContext;
4146

4247
mod cursor;
4348
mod direction;
44-
mod engine;
4549
pub mod fmt;
4650
pub mod graphviz;
4751
pub mod lattice;
52+
mod results;
4853
mod visitor;
4954

5055
pub use self::cursor::ResultsCursor;
5156
pub use self::direction::{Backward, Direction, Forward};
52-
pub use self::engine::{Engine, Results};
5357
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
58+
pub use self::results::Results;
5459
pub use self::visitor::{ResultsVisitable, ResultsVisitor, visit_results};
5560

5661
/// Analysis domains are all bitsets of various kinds. This trait holds
@@ -223,26 +228,92 @@ pub trait Analysis<'tcx> {
223228

224229
/* Extension methods */
225230

226-
/// Creates an `Engine` to find the fixpoint for this dataflow problem.
231+
/// Finds the fixpoint for this dataflow problem.
227232
///
228233
/// You shouldn't need to override this. Its purpose is to enable method chaining like so:
229234
///
230235
/// ```ignore (cross-crate-imports)
231236
/// let results = MyAnalysis::new(tcx, body)
232-
/// .into_engine(tcx, body, def_id)
233-
/// .iterate_to_fixpoint()
237+
/// .iterate_to_fixpoint(tcx, body, None)
234238
/// .into_results_cursor(body);
235239
/// ```
236-
#[inline]
237-
fn into_engine<'mir>(
238-
self,
240+
/// You can optionally add a `pass_name` to the graphviz output for this particular run of a
241+
/// dataflow analysis. Some analyses are run multiple times in the compilation pipeline.
242+
/// Without a `pass_name` to differentiates them, only the results for the latest run will be
243+
/// saved.
244+
fn iterate_to_fixpoint<'mir>(
245+
mut self,
239246
tcx: TyCtxt<'tcx>,
240247
body: &'mir mir::Body<'tcx>,
241-
) -> Engine<'mir, 'tcx, Self>
248+
pass_name: Option<&'static str>,
249+
) -> Results<'tcx, Self>
242250
where
243251
Self: Sized,
252+
Self::Domain: DebugWithContext<Self>,
244253
{
245-
Engine::new(tcx, body, self)
254+
let mut entry_sets =
255+
IndexVec::from_fn_n(|_| self.bottom_value(body), body.basic_blocks.len());
256+
self.initialize_start_block(body, &mut entry_sets[mir::START_BLOCK]);
257+
258+
if Self::Direction::IS_BACKWARD && entry_sets[mir::START_BLOCK] != self.bottom_value(body) {
259+
bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
260+
}
261+
262+
let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_none(body.basic_blocks.len());
263+
264+
if Self::Direction::IS_FORWARD {
265+
for (bb, _) in traversal::reverse_postorder(body) {
266+
dirty_queue.insert(bb);
267+
}
268+
} else {
269+
// Reverse post-order on the reverse CFG may generate a better iteration order for
270+
// backward dataflow analyses, but probably not enough to matter.
271+
for (bb, _) in traversal::postorder(body) {
272+
dirty_queue.insert(bb);
273+
}
274+
}
275+
276+
// `state` is not actually used between iterations;
277+
// this is just an optimization to avoid reallocating
278+
// every iteration.
279+
let mut state = self.bottom_value(body);
280+
while let Some(bb) = dirty_queue.pop() {
281+
let bb_data = &body[bb];
282+
283+
// Set the state to the entry state of the block.
284+
// This is equivalent to `state = entry_sets[bb].clone()`,
285+
// but it saves an allocation, thus improving compile times.
286+
state.clone_from(&entry_sets[bb]);
287+
288+
// Apply the block transfer function, using the cached one if it exists.
289+
let edges = Self::Direction::apply_effects_in_block(&mut self, &mut state, bb, bb_data);
290+
291+
Self::Direction::join_state_into_successors_of(
292+
&mut self,
293+
body,
294+
&mut state,
295+
bb,
296+
edges,
297+
|target: BasicBlock, state: &Self::Domain| {
298+
let set_changed = entry_sets[target].join(state);
299+
if set_changed {
300+
dirty_queue.insert(target);
301+
}
302+
},
303+
);
304+
}
305+
306+
let results = Results { analysis: self, entry_sets };
307+
308+
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
309+
let (res, results) = write_graphviz_results(tcx, body, results, pass_name);
310+
if let Err(e) = res {
311+
error!("Failed to write graphviz dataflow results: {}", e);
312+
}
313+
results
314+
} else {
315+
results
316+
}
246317
}
247318
}
248319

‎compiler/rustc_mir_dataflow/src/framework/engine.rs renamed to ‎compiler/rustc_mir_dataflow/src/framework/results.rs

Lines changed: 5 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
//! A solver for dataflow problems.
1+
//! Dataflow analysis results.
22
33
use std::ffi::OsString;
44
use std::path::PathBuf;
55

6-
use rustc_data_structures::work_queue::WorkQueue;
76
use rustc_hir::def_id::DefId;
87
use rustc_index::IndexVec;
9-
use rustc_middle::bug;
108
use rustc_middle::mir::{self, BasicBlock, create_dump_file, dump_enabled, traversal};
119
use rustc_middle::ty::TyCtxt;
1210
use rustc_middle::ty::print::with_no_trimmed_paths;
1311
use rustc_span::symbol::{Symbol, sym};
14-
use tracing::{debug, error};
12+
use tracing::debug;
1513
use {rustc_ast as ast, rustc_graphviz as dot};
1614

1715
use super::fmt::DebugWithContext;
18-
use super::{
19-
Analysis, Direction, JoinSemiLattice, ResultsCursor, ResultsVisitor, graphviz, visit_results,
20-
};
16+
use super::{Analysis, ResultsCursor, ResultsVisitor, graphviz, visit_results};
2117
use crate::errors::{
2218
DuplicateValuesFor, PathMustEndInFilename, RequiresAnArgument, UnknownFormatter,
2319
};
@@ -65,124 +61,17 @@ where
6561
body: &'mir mir::Body<'tcx>,
6662
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
6763
) {
68-
let blocks = mir::traversal::reachable(body);
64+
let blocks = traversal::reachable(body);
6965
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
7066
}
7167
}
7268

73-
/// A solver for dataflow problems.
74-
pub struct Engine<'mir, 'tcx, A>
75-
where
76-
A: Analysis<'tcx>,
77-
{
78-
tcx: TyCtxt<'tcx>,
79-
body: &'mir mir::Body<'tcx>,
80-
entry_sets: IndexVec<BasicBlock, A::Domain>,
81-
pass_name: Option<&'static str>,
82-
analysis: A,
83-
}
84-
85-
impl<'mir, 'tcx, A, D> Engine<'mir, 'tcx, A>
86-
where
87-
A: Analysis<'tcx, Domain = D>,
88-
D: Clone + JoinSemiLattice,
89-
{
90-
/// Creates a new `Engine` to solve a dataflow problem with an arbitrary transfer
91-
/// function.
92-
pub(crate) fn new(tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>, analysis: A) -> Self {
93-
let mut entry_sets =
94-
IndexVec::from_fn_n(|_| analysis.bottom_value(body), body.basic_blocks.len());
95-
analysis.initialize_start_block(body, &mut entry_sets[mir::START_BLOCK]);
96-
97-
if A::Direction::IS_BACKWARD && entry_sets[mir::START_BLOCK] != analysis.bottom_value(body)
98-
{
99-
bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
100-
}
101-
102-
Engine { analysis, tcx, body, pass_name: None, entry_sets }
103-
}
104-
105-
/// Adds an identifier to the graphviz output for this particular run of a dataflow analysis.
106-
///
107-
/// Some analyses are run multiple times in the compilation pipeline. Give them a `pass_name`
108-
/// to differentiate them. Otherwise, only the results for the latest run will be saved.
109-
pub fn pass_name(mut self, name: &'static str) -> Self {
110-
self.pass_name = Some(name);
111-
self
112-
}
113-
114-
/// Computes the fixpoint for this dataflow problem and returns it.
115-
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
116-
where
117-
A::Domain: DebugWithContext<A>,
118-
{
119-
let Engine { mut analysis, body, mut entry_sets, tcx, pass_name } = self;
120-
121-
let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_none(body.basic_blocks.len());
122-
123-
if A::Direction::IS_FORWARD {
124-
for (bb, _) in traversal::reverse_postorder(body) {
125-
dirty_queue.insert(bb);
126-
}
127-
} else {
128-
// Reverse post-order on the reverse CFG may generate a better iteration order for
129-
// backward dataflow analyses, but probably not enough to matter.
130-
for (bb, _) in traversal::postorder(body) {
131-
dirty_queue.insert(bb);
132-
}
133-
}
134-
135-
// `state` is not actually used between iterations;
136-
// this is just an optimization to avoid reallocating
137-
// every iteration.
138-
let mut state = analysis.bottom_value(body);
139-
while let Some(bb) = dirty_queue.pop() {
140-
let bb_data = &body[bb];
141-
142-
// Set the state to the entry state of the block.
143-
// This is equivalent to `state = entry_sets[bb].clone()`,
144-
// but it saves an allocation, thus improving compile times.
145-
state.clone_from(&entry_sets[bb]);
146-
147-
// Apply the block transfer function, using the cached one if it exists.
148-
let edges =
149-
A::Direction::apply_effects_in_block(&mut analysis, &mut state, bb, bb_data);
150-
151-
A::Direction::join_state_into_successors_of(
152-
&mut analysis,
153-
body,
154-
&mut state,
155-
bb,
156-
edges,
157-
|target: BasicBlock, state: &A::Domain| {
158-
let set_changed = entry_sets[target].join(state);
159-
if set_changed {
160-
dirty_queue.insert(target);
161-
}
162-
},
163-
);
164-
}
165-
166-
let results = Results { analysis, entry_sets };
167-
168-
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
169-
let (res, results) = write_graphviz_results(tcx, body, results, pass_name);
170-
if let Err(e) = res {
171-
error!("Failed to write graphviz dataflow results: {}", e);
172-
}
173-
results
174-
} else {
175-
results
176-
}
177-
}
178-
}
179-
18069
// Graphviz
18170

18271
/// Writes a DOT file containing the results of a dataflow analysis if the user requested it via
18372
/// `rustc_mir` attributes and `-Z dump-mir-dataflow`. The `Result` in and the `Results` out are
18473
/// the same.
185-
fn write_graphviz_results<'tcx, A>(
74+
pub(super) fn write_graphviz_results<'tcx, A>(
18675
tcx: TyCtxt<'tcx>,
18776
body: &mir::Body<'tcx>,
18877
results: Results<'tcx, A>,

‎compiler/rustc_mir_dataflow/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ pub use self::drop_flag_effects::{
1818
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
1919
};
2020
pub use self::framework::{
21-
Analysis, Backward, Direction, Engine, Forward, GenKill, JoinSemiLattice, MaybeReachable,
22-
Results, ResultsCursor, ResultsVisitable, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz,
23-
lattice, visit_results,
21+
Analysis, Backward, Direction, Forward, GenKill, JoinSemiLattice, MaybeReachable, Results,
22+
ResultsCursor, ResultsVisitable, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz, lattice,
23+
visit_results,
2424
};
2525
use self::move_paths::MoveData;
2626

‎compiler/rustc_mir_dataflow/src/rustc_peek.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,28 @@ pub fn sanity_check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
4343
let move_data = MoveData::gather_moves(body, tcx, |_| true);
4444

4545
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_maybe_init).is_some() {
46-
let flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
47-
.into_engine(tcx, body)
48-
.iterate_to_fixpoint();
46+
let flow_inits =
47+
MaybeInitializedPlaces::new(tcx, body, &move_data).iterate_to_fixpoint(tcx, body, None);
4948

5049
sanity_check_via_rustc_peek(tcx, flow_inits.into_results_cursor(body));
5150
}
5251

5352
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_maybe_uninit).is_some() {
5453
let flow_uninits = MaybeUninitializedPlaces::new(tcx, body, &move_data)
55-
.into_engine(tcx, body)
56-
.iterate_to_fixpoint();
54+
.iterate_to_fixpoint(tcx, body, None);
5755

5856
sanity_check_via_rustc_peek(tcx, flow_uninits.into_results_cursor(body));
5957
}
6058

6159
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_definite_init).is_some() {
62-
let flow_def_inits = DefinitelyInitializedPlaces::new(body, &move_data)
63-
.into_engine(tcx, body)
64-
.iterate_to_fixpoint();
60+
let flow_def_inits =
61+
DefinitelyInitializedPlaces::new(body, &move_data).iterate_to_fixpoint(tcx, body, None);
6562

6663
sanity_check_via_rustc_peek(tcx, flow_def_inits.into_results_cursor(body));
6764
}
6865

6966
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_liveness).is_some() {
70-
let flow_liveness = MaybeLiveLocals.into_engine(tcx, body).iterate_to_fixpoint();
67+
let flow_liveness = MaybeLiveLocals.iterate_to_fixpoint(tcx, body, None);
7168

7269
sanity_check_via_rustc_peek(tcx, flow_liveness.into_results_cursor(body));
7370
}

‎compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,31 +666,26 @@ fn locals_live_across_suspend_points<'tcx>(
666666
// Calculate when MIR locals have live storage. This gives us an upper bound of their
667667
// lifetimes.
668668
let mut storage_live = MaybeStorageLive::new(std::borrow::Cow::Borrowed(always_live_locals))
669-
.into_engine(tcx, body)
670-
.iterate_to_fixpoint()
669+
.iterate_to_fixpoint(tcx, body, None)
671670
.into_results_cursor(body);
672671

673672
// Calculate the MIR locals which have been previously
674673
// borrowed (even if they are still active).
675674
let borrowed_locals_results =
676-
MaybeBorrowedLocals.into_engine(tcx, body).pass_name("coroutine").iterate_to_fixpoint();
675+
MaybeBorrowedLocals.iterate_to_fixpoint(tcx, body, Some("coroutine"));
677676

678677
let mut borrowed_locals_cursor = borrowed_locals_results.clone().into_results_cursor(body);
679678

680679
// Calculate the MIR locals that we actually need to keep storage around
681680
// for.
682681
let mut requires_storage_cursor =
683682
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
684-
.into_engine(tcx, body)
685-
.iterate_to_fixpoint()
683+
.iterate_to_fixpoint(tcx, body, None)
686684
.into_results_cursor(body);
687685

688686
// Calculate the liveness of MIR locals ignoring borrows.
689-
let mut liveness = MaybeLiveLocals
690-
.into_engine(tcx, body)
691-
.pass_name("coroutine")
692-
.iterate_to_fixpoint()
693-
.into_results_cursor(body);
687+
let mut liveness =
688+
MaybeLiveLocals.iterate_to_fixpoint(tcx, body, Some("coroutine")).into_results_cursor(body);
694689

695690
let mut storage_liveness_map = IndexVec::from_elem(None, &body.basic_blocks);
696691
let mut live_locals_at_suspension_points = Vec::new();

‎compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'tcx> crate::MirPass<'tcx> for DataflowConstProp {
5959
// Perform the actual dataflow analysis.
6060
let analysis = ConstAnalysis::new(tcx, body, map);
6161
let mut results = debug_span!("analyze")
62-
.in_scope(|| analysis.wrap().into_engine(tcx, body).iterate_to_fixpoint());
62+
.in_scope(|| analysis.wrap().iterate_to_fixpoint(tcx, body, None));
6363

6464
// Collect results and patch the body afterwards.
6565
let mut visitor = Collector::new(tcx, &body.local_decls);

‎compiler/rustc_mir_transform/src/dead_store_elimination.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
3737
always_live.union(&borrowed_locals);
3838

3939
let mut live = MaybeTransitiveLiveLocals::new(&always_live)
40-
.into_engine(tcx, body)
41-
.iterate_to_fixpoint()
40+
.iterate_to_fixpoint(tcx, body, None)
4241
.into_results_cursor(body);
4342

4443
// For blocks with a call terminator, if an argument copy can be turned into a move,

‎compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
169169

170170
let borrowed = rustc_mir_dataflow::impls::borrowed_locals(body);
171171

172-
let live = MaybeLiveLocals
173-
.into_engine(tcx, body)
174-
.pass_name("MaybeLiveLocals-DestinationPropagation")
175-
.iterate_to_fixpoint();
172+
let live = MaybeLiveLocals.iterate_to_fixpoint(tcx, body, Some("MaybeLiveLocals-DestProp"));
176173
let points = DenseLocationMap::new(body);
177174
let mut live = save_as_intervals(&points, body, live);
178175

‎compiler/rustc_mir_transform/src/elaborate_drops.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateDrops {
6464

6565
let mut inits = MaybeInitializedPlaces::new(tcx, body, &env.move_data)
6666
.skipping_unreachable_unwind()
67-
.into_engine(tcx, body)
68-
.pass_name("elaborate_drops")
69-
.iterate_to_fixpoint()
67+
.iterate_to_fixpoint(tcx, body, Some("elaborate_drops"))
7068
.into_results_cursor(body);
7169
let dead_unwinds = compute_dead_unwinds(body, &mut inits);
7270

7371
let uninits = MaybeUninitializedPlaces::new(tcx, body, &env.move_data)
7472
.mark_inactive_variants_as_uninit()
7573
.skipping_unreachable_unwind(dead_unwinds)
76-
.into_engine(tcx, body)
77-
.pass_name("elaborate_drops")
78-
.iterate_to_fixpoint()
74+
.iterate_to_fixpoint(tcx, body, Some("elaborate_drops"))
7975
.into_results_cursor(body);
8076

8177
let drop_flags = IndexVec::from_elem(None, &env.move_data.move_paths);

‎compiler/rustc_mir_transform/src/lint.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ pub(super) fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String
1717
let always_live_locals = &always_storage_live_locals(body);
1818

1919
let maybe_storage_live = MaybeStorageLive::new(Cow::Borrowed(always_live_locals))
20-
.into_engine(tcx, body)
21-
.iterate_to_fixpoint()
20+
.iterate_to_fixpoint(tcx, body, None)
2221
.into_results_cursor(body);
2322

2423
let maybe_storage_dead = MaybeStorageDead::new(Cow::Borrowed(always_live_locals))
25-
.into_engine(tcx, body)
26-
.iterate_to_fixpoint()
24+
.iterate_to_fixpoint(tcx, body, None)
2725
.into_results_cursor(body);
2826

2927
let mut lint = Lint {

‎compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ fn compute_replacement<'tcx>(
126126
// Compute `MaybeStorageDead` dataflow to check that we only replace when the pointee is
127127
// definitely live.
128128
let mut maybe_dead = MaybeStorageDead::new(Cow::Owned(always_live_locals))
129-
.into_engine(tcx, body)
130-
.iterate_to_fixpoint()
129+
.iterate_to_fixpoint(tcx, body, None)
131130
.into_results_cursor(body);
132131

133132
// Map for each local to the pointee.

‎compiler/rustc_mir_transform/src/remove_uninit_drops.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveUninitDrops {
2222
let move_data = MoveData::gather_moves(body, tcx, |ty| ty.needs_drop(tcx, param_env));
2323

2424
let mut maybe_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
25-
.into_engine(tcx, body)
26-
.pass_name("remove_uninit_drops")
27-
.iterate_to_fixpoint()
25+
.iterate_to_fixpoint(tcx, body, Some("remove_uninit_drops"))
2826
.into_results_cursor(body);
2927

3028
let mut to_remove = vec![];

‎src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
185185
vis.into_map(cx)
186186
};
187187
let maybe_storage_live_result = MaybeStorageLive::new(Cow::Owned(BitSet::new_empty(mir.local_decls.len())))
188-
.into_engine(cx.tcx, mir)
189-
.pass_name("redundant_clone")
190-
.iterate_to_fixpoint()
188+
.iterate_to_fixpoint(cx.tcx, mir, Some("redundant_clone"))
191189
.into_results_cursor(mir);
192190
let mut vis = PossibleBorrowerVisitor::new(cx, mir, possible_origin);
193191
vis.visit_body(mir);

0 commit comments

Comments
 (0)
Please sign in to comment.