Remove unused arguments from on_all_children_bits
.
`on_all_children_bits` has two arguments that are unused: `tcx` and `body`. This was not detected by the compiler because it's a recursive function. This commit removes them, and removes lots of other arguments and fields that are no longer necessary.
This commit is contained in:
parent
118308ee03
commit
0f12da17c0
4 changed files with 42 additions and 90 deletions
|
@ -1,6 +1,5 @@
|
||||||
use crate::elaborate_drops::DropFlagState;
|
use crate::elaborate_drops::DropFlagState;
|
||||||
use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
|
use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
|
||||||
use rustc_middle::ty::TyCtxt;
|
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
|
||||||
use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
|
use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
|
||||||
|
@ -29,8 +28,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_lookup_result_bits<'tcx, F>(
|
pub fn on_lookup_result_bits<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
lookup_result: LookupResult,
|
lookup_result: LookupResult,
|
||||||
each_child: F,
|
each_child: F,
|
||||||
|
@ -41,13 +38,11 @@ pub fn on_lookup_result_bits<'tcx, F>(
|
||||||
LookupResult::Parent(..) => {
|
LookupResult::Parent(..) => {
|
||||||
// access to untracked value - do not touch children
|
// access to untracked value - do not touch children
|
||||||
}
|
}
|
||||||
LookupResult::Exact(e) => on_all_children_bits(tcx, body, move_data, e, each_child),
|
LookupResult::Exact(e) => on_all_children_bits(move_data, e, each_child),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_all_children_bits<'tcx, F>(
|
pub fn on_all_children_bits<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
move_path_index: MovePathIndex,
|
move_path_index: MovePathIndex,
|
||||||
mut each_child: F,
|
mut each_child: F,
|
||||||
|
@ -55,8 +50,6 @@ pub fn on_all_children_bits<'tcx, F>(
|
||||||
F: FnMut(MovePathIndex),
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
fn on_all_children_bits<'tcx, F>(
|
fn on_all_children_bits<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
move_path_index: MovePathIndex,
|
move_path_index: MovePathIndex,
|
||||||
each_child: &mut F,
|
each_child: &mut F,
|
||||||
|
@ -67,15 +60,14 @@ pub fn on_all_children_bits<'tcx, F>(
|
||||||
|
|
||||||
let mut next_child_index = move_data.move_paths[move_path_index].first_child;
|
let mut next_child_index = move_data.move_paths[move_path_index].first_child;
|
||||||
while let Some(child_index) = next_child_index {
|
while let Some(child_index) = next_child_index {
|
||||||
on_all_children_bits(tcx, body, move_data, child_index, each_child);
|
on_all_children_bits(move_data, child_index, each_child);
|
||||||
next_child_index = move_data.move_paths[child_index].next_sibling;
|
next_child_index = move_data.move_paths[child_index].next_sibling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child);
|
on_all_children_bits(move_data, move_path_index, &mut each_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
|
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
ctxt: &MoveDataParamEnv<'tcx>,
|
ctxt: &MoveDataParamEnv<'tcx>,
|
||||||
mut callback: F,
|
mut callback: F,
|
||||||
|
@ -86,14 +78,13 @@ pub fn drop_flag_effects_for_function_entry<'tcx, F>(
|
||||||
for arg in body.args_iter() {
|
for arg in body.args_iter() {
|
||||||
let place = mir::Place::from(arg);
|
let place = mir::Place::from(arg);
|
||||||
let lookup_result = move_data.rev_lookup.find(place.as_ref());
|
let lookup_result = move_data.rev_lookup.find(place.as_ref());
|
||||||
on_lookup_result_bits(tcx, body, move_data, lookup_result, |mpi| {
|
on_lookup_result_bits(move_data, lookup_result, |mpi| {
|
||||||
callback(mpi, DropFlagState::Present)
|
callback(mpi, DropFlagState::Present)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn drop_flag_effects_for_location<'tcx, F>(
|
pub fn drop_flag_effects_for_location<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
ctxt: &MoveDataParamEnv<'tcx>,
|
ctxt: &MoveDataParamEnv<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
|
@ -109,7 +100,7 @@ pub fn drop_flag_effects_for_location<'tcx, F>(
|
||||||
let path = mi.move_path_index(move_data);
|
let path = mi.move_path_index(move_data);
|
||||||
debug!("moving out of path {:?}", move_data.move_paths[path]);
|
debug!("moving out of path {:?}", move_data.move_paths[path]);
|
||||||
|
|
||||||
on_all_children_bits(tcx, body, move_data, path, |mpi| callback(mpi, DropFlagState::Absent))
|
on_all_children_bits(move_data, path, |mpi| callback(mpi, DropFlagState::Absent))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop does not count as a move but we should still consider the variable uninitialized.
|
// Drop does not count as a move but we should still consider the variable uninitialized.
|
||||||
|
@ -117,24 +108,17 @@ pub fn drop_flag_effects_for_location<'tcx, F>(
|
||||||
body.stmt_at(loc).right()
|
body.stmt_at(loc).right()
|
||||||
{
|
{
|
||||||
if let LookupResult::Exact(mpi) = move_data.rev_lookup.find(place.as_ref()) {
|
if let LookupResult::Exact(mpi) = move_data.rev_lookup.find(place.as_ref()) {
|
||||||
on_all_children_bits(tcx, body, move_data, mpi, |mpi| {
|
on_all_children_bits(move_data, mpi, |mpi| callback(mpi, DropFlagState::Absent))
|
||||||
callback(mpi, DropFlagState::Absent)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("drop_flag_effects: assignment for location({:?})", loc);
|
debug!("drop_flag_effects: assignment for location({:?})", loc);
|
||||||
|
|
||||||
for_location_inits(tcx, body, move_data, loc, |mpi| callback(mpi, DropFlagState::Present));
|
for_location_inits(move_data, loc, |mpi| callback(mpi, DropFlagState::Present));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_location_inits<'tcx, F>(
|
fn for_location_inits<'tcx, F>(move_data: &MoveData<'tcx>, loc: Location, mut callback: F)
|
||||||
tcx: TyCtxt<'tcx>,
|
where
|
||||||
body: &Body<'tcx>,
|
|
||||||
move_data: &MoveData<'tcx>,
|
|
||||||
loc: Location,
|
|
||||||
mut callback: F,
|
|
||||||
) where
|
|
||||||
F: FnMut(MovePathIndex),
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
for ii in &move_data.init_loc_map[loc] {
|
for ii in &move_data.init_loc_map[loc] {
|
||||||
|
@ -143,7 +127,7 @@ fn for_location_inits<'tcx, F>(
|
||||||
InitKind::Deep => {
|
InitKind::Deep => {
|
||||||
let path = init.path;
|
let path = init.path;
|
||||||
|
|
||||||
on_all_children_bits(tcx, body, move_data, path, &mut callback)
|
on_all_children_bits(move_data, path, &mut callback)
|
||||||
}
|
}
|
||||||
InitKind::Shallow => {
|
InitKind::Shallow => {
|
||||||
let mpi = init.path;
|
let mpi = init.path;
|
||||||
|
@ -160,8 +144,6 @@ fn for_location_inits<'tcx, F>(
|
||||||
/// NOTE: If there are no move paths corresponding to an inactive variant,
|
/// NOTE: If there are no move paths corresponding to an inactive variant,
|
||||||
/// `handle_inactive_variant` will not be called for that variant.
|
/// `handle_inactive_variant` will not be called for that variant.
|
||||||
pub(crate) fn on_all_inactive_variants<'tcx>(
|
pub(crate) fn on_all_inactive_variants<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &mir::Body<'tcx>,
|
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
enum_place: mir::Place<'tcx>,
|
enum_place: mir::Place<'tcx>,
|
||||||
active_variant: VariantIdx,
|
active_variant: VariantIdx,
|
||||||
|
@ -184,9 +166,7 @@ pub(crate) fn on_all_inactive_variants<'tcx>(
|
||||||
};
|
};
|
||||||
|
|
||||||
if variant_idx != active_variant {
|
if variant_idx != active_variant {
|
||||||
on_all_children_bits(tcx, body, move_data, variant_mpi, |mpi| {
|
on_all_children_bits(move_data, variant_mpi, |mpi| handle_inactive_variant(mpi));
|
||||||
handle_inactive_variant(mpi)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
|
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
|
||||||
let mut maybe_live = false;
|
let mut maybe_live = false;
|
||||||
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
on_all_children_bits(self.move_data(), path, |child| {
|
||||||
maybe_live |= state.contains(child);
|
maybe_live |= state.contains(child);
|
||||||
});
|
});
|
||||||
!maybe_live
|
!maybe_live
|
||||||
|
@ -203,14 +203,13 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'tcx> {
|
||||||
/// this data and `MaybeInitializedPlaces` yields the set of places
|
/// this data and `MaybeInitializedPlaces` yields the set of places
|
||||||
/// that would require a dynamic drop-flag at that statement.
|
/// that would require a dynamic drop-flag at that statement.
|
||||||
pub struct DefinitelyInitializedPlaces<'a, 'tcx> {
|
pub struct DefinitelyInitializedPlaces<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &'a Body<'tcx>,
|
body: &'a Body<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'tcx>,
|
mdpe: &'a MoveDataParamEnv<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
|
impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
|
pub fn new(body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
|
||||||
DefinitelyInitializedPlaces { tcx, body, mdpe }
|
DefinitelyInitializedPlaces { body, mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +316,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
|
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
|
||||||
*state =
|
*state =
|
||||||
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
|
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
|
||||||
drop_flag_effects_for_function_entry(self.tcx, self.body, self.mdpe, |path, s| {
|
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
|
||||||
assert!(s == DropFlagState::Present);
|
assert!(s == DropFlagState::Present);
|
||||||
state.gen(path);
|
state.gen(path);
|
||||||
});
|
});
|
||||||
|
@ -337,7 +336,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(trans, path, s)
|
Self::update_bits(trans, path, s)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -349,7 +348,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
| mir::Rvalue::AddressOf(_, place) = rvalue
|
| mir::Rvalue::AddressOf(_, place) = rvalue
|
||||||
&& let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
|
&& let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
|
||||||
{
|
{
|
||||||
on_all_children_bits(self.tcx, self.body, self.move_data(), mpi, |child| {
|
on_all_children_bits(self.move_data(), mpi, |child| {
|
||||||
trans.gen(child);
|
trans.gen(child);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -369,7 +368,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
{
|
{
|
||||||
edges = TerminatorEdges::Single(target);
|
edges = TerminatorEdges::Single(target);
|
||||||
}
|
}
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(state, path, s)
|
Self::update_bits(state, path, s)
|
||||||
});
|
});
|
||||||
edges
|
edges
|
||||||
|
@ -385,8 +384,6 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
// when a call returns successfully, that means we need to set
|
// when a call returns successfully, that means we need to set
|
||||||
// the bits for that dest_place to 1 (initialized).
|
// the bits for that dest_place to 1 (initialized).
|
||||||
on_lookup_result_bits(
|
on_lookup_result_bits(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
self.move_data().rev_lookup.find(place.as_ref()),
|
self.move_data().rev_lookup.find(place.as_ref()),
|
||||||
|mpi| {
|
|mpi| {
|
||||||
|
@ -430,8 +427,6 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
// Kill all move paths that correspond to variants we know to be inactive along this
|
// Kill all move paths that correspond to variants we know to be inactive along this
|
||||||
// particular outgoing edge of a `SwitchInt`.
|
// particular outgoing edge of a `SwitchInt`.
|
||||||
drop_flag_effects::on_all_inactive_variants(
|
drop_flag_effects::on_all_inactive_variants(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
enum_place,
|
enum_place,
|
||||||
variant,
|
variant,
|
||||||
|
@ -456,7 +451,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
// set all bits to 1 (uninit) before gathering counter-evidence
|
// set all bits to 1 (uninit) before gathering counter-evidence
|
||||||
state.insert_all();
|
state.insert_all();
|
||||||
|
|
||||||
drop_flag_effects_for_function_entry(self.tcx, self.body, self.mdpe, |path, s| {
|
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
|
||||||
assert!(s == DropFlagState::Present);
|
assert!(s == DropFlagState::Present);
|
||||||
state.remove(path);
|
state.remove(path);
|
||||||
});
|
});
|
||||||
|
@ -476,7 +471,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(trans, path, s)
|
Self::update_bits(trans, path, s)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -490,7 +485,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) -> TerminatorEdges<'mir, 'tcx> {
|
) -> TerminatorEdges<'mir, 'tcx> {
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(trans, path, s)
|
Self::update_bits(trans, path, s)
|
||||||
});
|
});
|
||||||
if self.skip_unreachable_unwind.contains(location.block) {
|
if self.skip_unreachable_unwind.contains(location.block) {
|
||||||
|
@ -512,8 +507,6 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
// when a call returns successfully, that means we need to set
|
// when a call returns successfully, that means we need to set
|
||||||
// the bits for that dest_place to 0 (initialized).
|
// the bits for that dest_place to 0 (initialized).
|
||||||
on_lookup_result_bits(
|
on_lookup_result_bits(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
self.move_data().rev_lookup.find(place.as_ref()),
|
self.move_data().rev_lookup.find(place.as_ref()),
|
||||||
|mpi| {
|
|mpi| {
|
||||||
|
@ -561,8 +554,6 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
// Mark all move paths that correspond to variants other than this one as maybe
|
// Mark all move paths that correspond to variants other than this one as maybe
|
||||||
// uninitialized (in reality, they are *definitely* uninitialized).
|
// uninitialized (in reality, they are *definitely* uninitialized).
|
||||||
drop_flag_effects::on_all_inactive_variants(
|
drop_flag_effects::on_all_inactive_variants(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
enum_place,
|
enum_place,
|
||||||
variant,
|
variant,
|
||||||
|
@ -587,7 +578,7 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
|
||||||
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
|
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
|
||||||
state.0.clear();
|
state.0.clear();
|
||||||
|
|
||||||
drop_flag_effects_for_function_entry(self.tcx, self.body, self.mdpe, |path, s| {
|
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
|
||||||
assert!(s == DropFlagState::Present);
|
assert!(s == DropFlagState::Present);
|
||||||
state.0.insert(path);
|
state.0.insert(path);
|
||||||
});
|
});
|
||||||
|
@ -607,7 +598,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(trans, path, s)
|
Self::update_bits(trans, path, s)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -618,7 +609,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) -> TerminatorEdges<'mir, 'tcx> {
|
) -> TerminatorEdges<'mir, 'tcx> {
|
||||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
drop_flag_effects_for_location(self.body, self.mdpe, location, |path, s| {
|
||||||
Self::update_bits(trans, path, s)
|
Self::update_bits(trans, path, s)
|
||||||
});
|
});
|
||||||
terminator.edges()
|
terminator.edges()
|
||||||
|
@ -634,8 +625,6 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
|
||||||
// when a call returns successfully, that means we need to set
|
// when a call returns successfully, that means we need to set
|
||||||
// the bits for that dest_place to 1 (initialized).
|
// the bits for that dest_place to 1 (initialized).
|
||||||
on_lookup_result_bits(
|
on_lookup_result_bits(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
self.move_data().rev_lookup.find(place.as_ref()),
|
self.move_data().rev_lookup.find(place.as_ref()),
|
||||||
|mpi| {
|
|mpi| {
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_definite_init).is_some() {
|
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_definite_init).is_some() {
|
||||||
let flow_def_inits = DefinitelyInitializedPlaces::new(tcx, body, &mdpe)
|
let flow_def_inits = DefinitelyInitializedPlaces::new(body, &mdpe)
|
||||||
.into_engine(tcx, body)
|
.into_engine(tcx, body)
|
||||||
.iterate_to_fixpoint();
|
.iterate_to_fixpoint();
|
||||||
|
|
||||||
|
|
|
@ -172,19 +172,13 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, 'tcx> {
|
||||||
let mut some_live = false;
|
let mut some_live = false;
|
||||||
let mut some_dead = false;
|
let mut some_dead = false;
|
||||||
let mut children_count = 0;
|
let mut children_count = 0;
|
||||||
on_all_children_bits(
|
on_all_children_bits(self.ctxt.move_data(), path, |child| {
|
||||||
self.tcx(),
|
|
||||||
self.body(),
|
|
||||||
self.ctxt.move_data(),
|
|
||||||
path,
|
|
||||||
|child| {
|
|
||||||
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
|
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
|
||||||
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
|
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
|
||||||
some_live |= live;
|
some_live |= live;
|
||||||
some_dead |= dead;
|
some_dead |= dead;
|
||||||
children_count += 1;
|
children_count += 1;
|
||||||
},
|
});
|
||||||
);
|
|
||||||
((some_live, some_dead), children_count != 1)
|
((some_live, some_dead), children_count != 1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -202,13 +196,9 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, 'tcx> {
|
||||||
self.ctxt.set_drop_flag(loc, path, DropFlagState::Absent);
|
self.ctxt.set_drop_flag(loc, path, DropFlagState::Absent);
|
||||||
}
|
}
|
||||||
DropFlagMode::Deep => {
|
DropFlagMode::Deep => {
|
||||||
on_all_children_bits(
|
on_all_children_bits(self.ctxt.move_data(), path, |child| {
|
||||||
self.tcx(),
|
self.ctxt.set_drop_flag(loc, child, DropFlagState::Absent)
|
||||||
self.body(),
|
});
|
||||||
self.ctxt.move_data(),
|
|
||||||
path,
|
|
||||||
|child| self.ctxt.set_drop_flag(loc, child, DropFlagState::Absent),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,10 +258,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_drop_flag(&mut self, index: MovePathIndex, span: Span) {
|
fn create_drop_flag(&mut self, index: MovePathIndex, span: Span) {
|
||||||
let tcx = self.tcx;
|
|
||||||
let patch = &mut self.patch;
|
let patch = &mut self.patch;
|
||||||
debug!("create_drop_flag({:?})", self.body.span);
|
debug!("create_drop_flag({:?})", self.body.span);
|
||||||
self.drop_flags[index].get_or_insert_with(|| patch.new_temp(tcx.types.bool, span));
|
self.drop_flags[index].get_or_insert_with(|| patch.new_temp(self.tcx.types.bool, span));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drop_flag(&mut self, index: MovePathIndex) -> Option<Place<'tcx>> {
|
fn drop_flag(&mut self, index: MovePathIndex) -> Option<Place<'tcx>> {
|
||||||
|
@ -304,7 +293,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
match path {
|
match path {
|
||||||
LookupResult::Exact(path) => {
|
LookupResult::Exact(path) => {
|
||||||
self.init_data.seek_before(self.body.terminator_loc(bb));
|
self.init_data.seek_before(self.body.terminator_loc(bb));
|
||||||
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
on_all_children_bits(self.move_data(), path, |child| {
|
||||||
let (maybe_live, maybe_dead) = self.init_data.maybe_live_dead(child);
|
let (maybe_live, maybe_dead) = self.init_data.maybe_live_dead(child);
|
||||||
debug!(
|
debug!(
|
||||||
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
|
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
|
||||||
|
@ -444,7 +433,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
|
|
||||||
let loc = Location { block: tgt, statement_index: 0 };
|
let loc = Location { block: tgt, statement_index: 0 };
|
||||||
let path = self.move_data().rev_lookup.find(destination.as_ref());
|
let path = self.move_data().rev_lookup.find(destination.as_ref());
|
||||||
on_lookup_result_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
on_lookup_result_bits(self.move_data(), path, |child| {
|
||||||
self.set_drop_flag(loc, child, DropFlagState::Present)
|
self.set_drop_flag(loc, child, DropFlagState::Present)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -453,14 +442,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
|
|
||||||
fn drop_flags_for_args(&mut self) {
|
fn drop_flags_for_args(&mut self) {
|
||||||
let loc = Location::START;
|
let loc = Location::START;
|
||||||
rustc_mir_dataflow::drop_flag_effects_for_function_entry(
|
rustc_mir_dataflow::drop_flag_effects_for_function_entry(self.body, self.env, |path, ds| {
|
||||||
self.tcx,
|
|
||||||
self.body,
|
|
||||||
self.env,
|
|
||||||
|path, ds| {
|
|
||||||
self.set_drop_flag(loc, path, ds);
|
self.set_drop_flag(loc, path, ds);
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drop_flags_for_locs(&mut self) {
|
fn drop_flags_for_locs(&mut self) {
|
||||||
|
@ -492,7 +476,6 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
}
|
}
|
||||||
let loc = Location { block: bb, statement_index: i };
|
let loc = Location { block: bb, statement_index: i };
|
||||||
rustc_mir_dataflow::drop_flag_effects_for_location(
|
rustc_mir_dataflow::drop_flag_effects_for_location(
|
||||||
self.tcx,
|
|
||||||
self.body,
|
self.body,
|
||||||
self.env,
|
self.env,
|
||||||
loc,
|
loc,
|
||||||
|
@ -515,7 +498,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
|
|
||||||
let loc = Location { block: bb, statement_index: data.statements.len() };
|
let loc = Location { block: bb, statement_index: data.statements.len() };
|
||||||
let path = self.move_data().rev_lookup.find(destination.as_ref());
|
let path = self.move_data().rev_lookup.find(destination.as_ref());
|
||||||
on_lookup_result_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
on_lookup_result_bits(self.move_data(), path, |child| {
|
||||||
self.set_drop_flag(loc, child, DropFlagState::Present)
|
self.set_drop_flag(loc, child, DropFlagState::Present)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue