Replace Body::basic_blocks()
with field access
This commit is contained in:
parent
983f4daddf
commit
b48870b451
65 changed files with 131 additions and 140 deletions
|
@ -108,9 +108,9 @@ where
|
|||
// Otherwise, compute and store the cumulative transfer function for each block.
|
||||
|
||||
let identity = GenKillSet::identity(analysis.bottom_value(body).domain_size());
|
||||
let mut trans_for_block = IndexVec::from_elem(identity, body.basic_blocks());
|
||||
let mut trans_for_block = IndexVec::from_elem(identity, &body.basic_blocks);
|
||||
|
||||
for (block, block_data) in body.basic_blocks().iter_enumerated() {
|
||||
for (block, block_data) in body.basic_blocks.iter_enumerated() {
|
||||
let trans = &mut trans_for_block[block];
|
||||
A::Direction::gen_kill_effects_in_block(&analysis, trans, block, block_data);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ where
|
|||
apply_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
|
||||
) -> Self {
|
||||
let bottom_value = analysis.bottom_value(body);
|
||||
let mut entry_sets = IndexVec::from_elem(bottom_value.clone(), body.basic_blocks());
|
||||
let mut entry_sets = IndexVec::from_elem(bottom_value.clone(), &body.basic_blocks);
|
||||
analysis.initialize_start_block(body, &mut entry_sets[mir::START_BLOCK]);
|
||||
|
||||
if A::Direction::IS_BACKWARD && entry_sets[mir::START_BLOCK] != bottom_value {
|
||||
|
@ -197,8 +197,7 @@ where
|
|||
..
|
||||
} = self;
|
||||
|
||||
let mut dirty_queue: WorkQueue<BasicBlock> =
|
||||
WorkQueue::with_none(body.basic_blocks().len());
|
||||
let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_none(body.basic_blocks.len());
|
||||
|
||||
if A::Direction::IS_FORWARD {
|
||||
for (bb, _) in traversal::reverse_postorder(body) {
|
||||
|
|
|
@ -108,12 +108,12 @@ where
|
|||
type Edge = CfgEdge;
|
||||
|
||||
fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
|
||||
self.body.basic_blocks().indices().collect::<Vec<_>>().into()
|
||||
self.body.basic_blocks.indices().collect::<Vec<_>>().into()
|
||||
}
|
||||
|
||||
fn edges(&self) -> dot::Edges<'_, Self::Edge> {
|
||||
self.body
|
||||
.basic_blocks()
|
||||
.basic_blocks
|
||||
.indices()
|
||||
.flat_map(|bb| dataflow_successors(self.body, bb))
|
||||
.collect::<Vec<_>>()
|
||||
|
|
|
@ -100,9 +100,9 @@ impl<D: Direction> MockAnalysis<'_, D> {
|
|||
|
||||
fn mock_entry_sets(&self) -> IndexVec<BasicBlock, BitSet<usize>> {
|
||||
let empty = self.bottom_value(self.body);
|
||||
let mut ret = IndexVec::from_elem(empty, &self.body.basic_blocks());
|
||||
let mut ret = IndexVec::from_elem(empty, &self.body.basic_blocks);
|
||||
|
||||
for (bb, _) in self.body.basic_blocks().iter_enumerated() {
|
||||
for (bb, _) in self.body.basic_blocks.iter_enumerated() {
|
||||
ret[bb] = self.mock_entry_set(bb);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl<'tcx, D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
|
|||
const NAME: &'static str = "mock";
|
||||
|
||||
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
|
||||
BitSet::new_empty(Self::BASIC_BLOCK_OFFSET + body.basic_blocks().len())
|
||||
BitSet::new_empty(Self::BASIC_BLOCK_OFFSET + body.basic_blocks.len())
|
||||
}
|
||||
|
||||
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {
|
||||
|
@ -271,9 +271,7 @@ fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
|
|||
cursor.allow_unreachable();
|
||||
|
||||
let every_target = || {
|
||||
body.basic_blocks()
|
||||
.iter_enumerated()
|
||||
.flat_map(|(bb, _)| SeekTarget::iter_in_block(body, bb))
|
||||
body.basic_blocks.iter_enumerated().flat_map(|(bb, _)| SeekTarget::iter_in_block(body, bb))
|
||||
};
|
||||
|
||||
let mut seek_to_target = |targ| {
|
||||
|
|
|
@ -243,7 +243,7 @@ pub(super) fn gather_moves<'tcx>(
|
|||
|
||||
builder.gather_args();
|
||||
|
||||
for (bb, block) in body.basic_blocks().iter_enumerated() {
|
||||
for (bb, block) in body.basic_blocks.iter_enumerated() {
|
||||
for (i, stmt) in block.statements.iter().enumerate() {
|
||||
let source = Location { block: bb, statement_index: i };
|
||||
builder.gather_statement(source, stmt);
|
||||
|
|
|
@ -217,7 +217,7 @@ where
|
|||
fn new(body: &Body<'_>) -> Self {
|
||||
LocationMap {
|
||||
map: body
|
||||
.basic_blocks()
|
||||
.basic_blocks
|
||||
.iter()
|
||||
.map(|block| vec![T::default(); block.statements.len() + 1])
|
||||
.collect(),
|
||||
|
|
|
@ -97,7 +97,7 @@ pub fn sanity_check_via_rustc_peek<'tcx, A>(
|
|||
|
||||
let mut cursor = ResultsCursor::new(body, results);
|
||||
|
||||
let peek_calls = body.basic_blocks().iter_enumerated().filter_map(|(bb, block_data)| {
|
||||
let peek_calls = body.basic_blocks.iter_enumerated().filter_map(|(bb, block_data)| {
|
||||
PeekCall::from_terminator(tcx, block_data.terminator()).map(|call| (bb, block_data, call))
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc_middle::mir::{self, Local};
|
|||
pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
|
||||
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
|
||||
|
||||
for block in body.basic_blocks() {
|
||||
for block in &*body.basic_blocks {
|
||||
for statement in &block.statements {
|
||||
use mir::StatementKind::{StorageDead, StorageLive};
|
||||
if let StorageLive(l) | StorageDead(l) = statement.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue