mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Refactor trait BitDenotation
to take Location
instead of BasicBlock
/usize
argument pairs.
This commit is contained in:
parent
8e79fc72cb
commit
cff060b960
@ -287,24 +287,22 @@ impl<'a, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'tcx> {
|
||||
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
idx: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: idx },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
statements_len: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: statements_len },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
@ -344,24 +342,22 @@ impl<'a, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'tcx> {
|
||||
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
idx: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: idx },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
statements_len: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: statements_len },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
@ -400,24 +396,22 @@ impl<'a, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'tcx> {
|
||||
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
idx: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: idx },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<MovePathIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
statements_len: usize)
|
||||
location: Location)
|
||||
{
|
||||
drop_flag_effects_for_location(
|
||||
self.tcx, self.mir, self.mdpe,
|
||||
Location { block: bb, statement_index: statements_len },
|
||||
location,
|
||||
|path, s| Self::update_bits(sets, path, s)
|
||||
)
|
||||
}
|
||||
@ -448,18 +442,16 @@ impl<'a, 'tcx> BitDenotation for MovingOutStatements<'a, 'tcx> {
|
||||
}
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<MoveOutIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
idx: usize) {
|
||||
location: Location) {
|
||||
let (tcx, mir, move_data) = (self.tcx, self.mir, self.move_data());
|
||||
let stmt = &mir[bb].statements[idx];
|
||||
let stmt = &mir[location.block].statements[location.statement_index];
|
||||
let loc_map = &move_data.loc_map;
|
||||
let path_map = &move_data.path_map;
|
||||
let rev_lookup = &move_data.rev_lookup;
|
||||
|
||||
let loc = Location { block: bb, statement_index: idx };
|
||||
debug!("stmt {:?} at loc {:?} moves out of move_indexes {:?}",
|
||||
stmt, loc, &loc_map[loc]);
|
||||
for move_index in &loc_map[loc] {
|
||||
stmt, location, &loc_map[location]);
|
||||
for move_index in &loc_map[location] {
|
||||
// Every path deinitialized by a *particular move*
|
||||
// has corresponding bit, "gen'ed" (i.e. set)
|
||||
// here, in dataflow vector
|
||||
@ -506,17 +498,15 @@ impl<'a, 'tcx> BitDenotation for MovingOutStatements<'a, 'tcx> {
|
||||
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<MoveOutIndex>,
|
||||
bb: mir::BasicBlock,
|
||||
statements_len: usize)
|
||||
location: Location)
|
||||
{
|
||||
let (mir, move_data) = (self.mir, self.move_data());
|
||||
let term = mir[bb].terminator();
|
||||
let term = mir[location.block].terminator();
|
||||
let loc_map = &move_data.loc_map;
|
||||
let loc = Location { block: bb, statement_index: statements_len };
|
||||
debug!("terminator {:?} at loc {:?} moves out of move_indexes {:?}",
|
||||
term, loc, &loc_map[loc]);
|
||||
term, location, &loc_map[location]);
|
||||
let bits_per_block = self.bits_per_block();
|
||||
for move_index in &loc_map[loc] {
|
||||
for move_index in &loc_map[location] {
|
||||
assert!(move_index.index() < bits_per_block);
|
||||
zero_to_one(sets.gen_set.words_mut(), *move_index);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use rustc_data_structures::indexed_vec::Idx;
|
||||
use rustc_data_structures::bitslice::{bitwise, BitwiseOperator};
|
||||
|
||||
use rustc::ty::{TyCtxt};
|
||||
use rustc::mir::{self, Mir};
|
||||
use rustc::mir::{self, Mir, Location};
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::io;
|
||||
@ -98,12 +98,13 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD>
|
||||
|
||||
let sets = &mut self.flow_state.sets.for_block(bb.index());
|
||||
for j_stmt in 0..statements.len() {
|
||||
self.flow_state.operator.statement_effect(sets, bb, j_stmt);
|
||||
let location = Location { block: bb, statement_index: j_stmt };
|
||||
self.flow_state.operator.statement_effect(sets, location);
|
||||
}
|
||||
|
||||
if terminator.is_some() {
|
||||
let stmts_len = statements.len();
|
||||
self.flow_state.operator.terminator_effect(sets, bb, stmts_len);
|
||||
let location = Location { block: bb, statement_index: statements.len() };
|
||||
self.flow_state.operator.terminator_effect(sets, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,8 +342,7 @@ pub trait BitDenotation {
|
||||
/// the MIR.
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<Self::Idx>,
|
||||
bb: mir::BasicBlock,
|
||||
idx_stmt: usize);
|
||||
location: Location);
|
||||
|
||||
/// Mutates the block-sets (the flow sets for the given
|
||||
/// basic block) according to the effects of evaluating
|
||||
@ -356,8 +356,7 @@ pub trait BitDenotation {
|
||||
/// terminator took.
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<Self::Idx>,
|
||||
bb: mir::BasicBlock,
|
||||
idx_term: usize);
|
||||
location: Location);
|
||||
|
||||
/// Mutates the block-sets according to the (flow-dependent)
|
||||
/// effect of a successful return from a Call terminator.
|
||||
|
@ -13,7 +13,7 @@ use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::mir::{self, Mir};
|
||||
use rustc::mir::{self, Mir, Location};
|
||||
use rustc::mir::transform::{MirPass, MirSource};
|
||||
use rustc_data_structures::indexed_set::IdxSetBuf;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
@ -202,7 +202,7 @@ fn each_block<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// reset GEN and KILL sets before emulating their effect.
|
||||
for e in sets.gen_set.words_mut() { *e = 0; }
|
||||
for e in sets.kill_set.words_mut() { *e = 0; }
|
||||
results.0.operator.statement_effect(&mut sets, bb, j);
|
||||
results.0.operator.statement_effect(&mut sets, Location { block: bb, statement_index: j });
|
||||
sets.on_entry.union(sets.gen_set);
|
||||
sets.on_entry.subtract(sets.kill_set);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user