Do not pre-compute reachable blocks.

This commit is contained in:
Camille GILLOT 2023-08-16 18:19:48 +00:00
parent f5e4eb91b7
commit 5b2524eb03
6 changed files with 18 additions and 26 deletions

View File

@ -74,12 +74,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
.iterate_to_fixpoint() .iterate_to_fixpoint()
.into_results_cursor(body); .into_results_cursor(body);
let dead_unwinds = compute_dead_unwinds(&body, &mut inits); let dead_unwinds = compute_dead_unwinds(&body, &mut inits);
let mut reachable = BitSet::new_empty(body.basic_blocks.len());
for bb in body.basic_blocks.indices() {
if inits.results().entry_set_for_block(bb).is_reachable() {
reachable.insert(bb);
}
}
let uninits = MaybeUninitializedPlaces::new(tcx, body, &env) let uninits = MaybeUninitializedPlaces::new(tcx, body, &env)
.mark_inactive_variants_as_uninit() .mark_inactive_variants_as_uninit()
@ -97,7 +91,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
init_data: InitializationData { inits, uninits }, init_data: InitializationData { inits, uninits },
drop_flags, drop_flags,
patch: MirPatch::new(body), patch: MirPatch::new(body),
reachable,
} }
.elaborate() .elaborate()
}; };
@ -262,7 +255,6 @@ struct ElaborateDropsCtxt<'a, 'tcx> {
init_data: InitializationData<'a, 'tcx>, init_data: InitializationData<'a, 'tcx>,
drop_flags: IndexVec<MovePathIndex, Option<Local>>, drop_flags: IndexVec<MovePathIndex, Option<Local>>,
patch: MirPatch<'tcx>, patch: MirPatch<'tcx>,
reachable: BitSet<BasicBlock>,
} }
impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
@ -302,9 +294,6 @@ fn elaborate(mut self) -> MirPatch<'tcx> {
fn collect_drop_flags(&mut self) { fn collect_drop_flags(&mut self) {
for (bb, data) in self.body.basic_blocks.iter_enumerated() { for (bb, data) in self.body.basic_blocks.iter_enumerated() {
if !self.reachable.contains(bb) {
continue;
}
let terminator = data.terminator(); let terminator = data.terminator();
let place = match terminator.kind { let place = match terminator.kind {
TerminatorKind::Drop { ref place, .. } => place, TerminatorKind::Drop { ref place, .. } => place,
@ -356,9 +345,6 @@ fn collect_drop_flags(&mut self) {
fn elaborate_drops(&mut self) { fn elaborate_drops(&mut self) {
for (bb, data) in self.body.basic_blocks.iter_enumerated() { for (bb, data) in self.body.basic_blocks.iter_enumerated() {
if !self.reachable.contains(bb) {
continue;
}
let loc = Location { block: bb, statement_index: data.statements.len() }; let loc = Location { block: bb, statement_index: data.statements.len() };
let terminator = data.terminator(); let terminator = data.terminator();
@ -437,9 +423,6 @@ fn drop_flags_on_init(&mut self) {
fn drop_flags_for_fn_rets(&mut self) { fn drop_flags_for_fn_rets(&mut self) {
for (bb, data) in self.body.basic_blocks.iter_enumerated() { for (bb, data) in self.body.basic_blocks.iter_enumerated() {
if !self.reachable.contains(bb) {
continue;
}
if let TerminatorKind::Call { if let TerminatorKind::Call {
destination, destination,
target: Some(tgt), target: Some(tgt),
@ -478,9 +461,6 @@ fn drop_flags_for_locs(&mut self) {
// clobbered before they are read. // clobbered before they are read.
for (bb, data) in self.body.basic_blocks.iter_enumerated() { for (bb, data) in self.body.basic_blocks.iter_enumerated() {
if !self.reachable.contains(bb) {
continue;
}
debug!("drop_flags_for_locs({:?})", data); debug!("drop_flags_for_locs({:?})", data);
for i in 0..(data.statements.len() + 1) { for i in 0..(data.statements.len() + 1) {
debug!("drop_flag_for_locs: stmt {}", i); debug!("drop_flag_for_locs: stmt {}", i);

View File

@ -47,7 +47,8 @@
bb2 (cleanup): { bb2 (cleanup): {
_5 = move _6; _5 = move _6;
drop(_6) -> [return: bb6, unwind terminate]; - drop(_6) -> [return: bb6, unwind terminate];
+ goto -> bb6;
} }
bb3: { bb3: {
@ -70,7 +71,8 @@
} }
bb6 (cleanup): { bb6 (cleanup): {
drop(_5) -> [return: bb7, unwind terminate]; - drop(_5) -> [return: bb7, unwind terminate];
+ goto -> bb7;
} }
bb7 (cleanup): { bb7 (cleanup): {

View File

@ -47,7 +47,8 @@
bb3 (cleanup): { bb3 (cleanup): {
_2 = move _5; _2 = move _5;
drop(_5) -> [return: bb8, unwind terminate]; - drop(_5) -> [return: bb8, unwind terminate];
+ goto -> bb8;
} }
bb4: { bb4: {

View File

@ -47,7 +47,8 @@
bb3 (cleanup): { bb3 (cleanup): {
_2 = move _5; _2 = move _5;
drop(_5) -> [return: bb8, unwind terminate]; - drop(_5) -> [return: bb8, unwind terminate];
+ goto -> bb8;
} }
bb4: { bb4: {

View File

@ -54,8 +54,12 @@
} }
bb4 (cleanup): { bb4 (cleanup): {
+ _7 = const true;
+ _8 = const true;
+ _9 = const true;
_1 = move _3; _1 = move _3;
drop(_3) -> [return: bb11, unwind terminate]; - drop(_3) -> [return: bb11, unwind terminate];
+ goto -> bb11;
} }
bb5: { bb5: {

View File

@ -54,8 +54,12 @@
} }
bb4 (cleanup): { bb4 (cleanup): {
+ _7 = const true;
+ _8 = const true;
+ _9 = const true;
_1 = move _3; _1 = move _3;
drop(_3) -> [return: bb11, unwind terminate]; - drop(_3) -> [return: bb11, unwind terminate];
+ goto -> bb11;
} }
bb5: { bb5: {