提交 39d9c1cb 编写于 作者: T Tomasz Miąsko

Move `predecessors` from Body to BasicBlocks

上级 2446b177
......@@ -1628,7 +1628,7 @@ fn predecessor_locations<'tcx, 'a>(
location: Location,
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
if location.statement_index == 0 {
let predecessors = body.predecessors()[location.block].to_vec();
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))
} else {
Either::Right(std::iter::once(Location {
......
......@@ -258,7 +258,7 @@ fn compute_use_live_points_for(&mut self, local: Local) {
let block = self.cx.elements.to_location(block_start).block;
self.stack.extend(
self.cx.body.predecessors()[block]
self.cx.body.basic_blocks.predecessors()[block]
.iter()
.map(|&pred_bb| self.cx.body.terminator_loc(pred_bb))
.map(|pred_loc| self.cx.elements.point_from_location(pred_loc)),
......@@ -354,7 +354,7 @@ fn compute_drop_live_points_for_block(&mut self, mpi: MovePathIndex, term_point:
}
let body = self.cx.body;
for &pred_block in body.predecessors()[block].iter() {
for &pred_block in body.basic_blocks.predecessors()[block].iter() {
debug!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,);
// Check whether the variable is (at least partially)
......
......@@ -41,7 +41,6 @@
use std::ops::{ControlFlow, Index, IndexMut};
use std::{iter, mem};
use self::predecessors::Predecessors;
pub use self::query::*;
use self::switch_sources::SwitchSources;
pub use basic_blocks::BasicBlocks;
......@@ -449,11 +448,6 @@ pub fn stmt_at(&self, location: Location) -> Either<&Statement<'tcx>, &Terminato
.unwrap_or_else(|| Either::Right(block_data.terminator()))
}
#[inline]
pub fn predecessors(&self) -> &Predecessors {
self.basic_blocks.predecessors()
}
/// `body.switch_sources()[&(target, switch)]` returns a list of switch
/// values that lead to a `target` block from a `switch` block.
#[inline]
......@@ -2837,7 +2831,7 @@ pub fn is_predecessor_of<'tcx>(&self, other: Location, body: &Body<'tcx>) -> boo
return true;
}
let predecessors = body.predecessors();
let predecessors = body.basic_blocks.predecessors();
// If we're in another block, then we want to check that block is a predecessor of `other`.
let mut queue: Vec<BasicBlock> = predecessors[other.block].to_vec();
......
......@@ -228,7 +228,7 @@ fn join_state_into_successors_of<'tcx, A>(
) where
A: Analysis<'tcx>,
{
for pred in body.predecessors()[bb].iter().copied() {
for pred in body.basic_blocks.predecessors()[bb].iter().copied() {
match body[pred].terminator().kind {
// Apply terminator-specific edge effects.
//
......
......@@ -39,7 +39,7 @@ fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
impl AddCallGuards {
pub fn add_call_guards(&self, body: &mut Body<'_>) {
let mut pred_count: IndexVec<_, _> =
body.predecessors().iter().map(|ps| ps.len()).collect();
body.basic_blocks.predecessors().iter().map(|ps| ps.len()).collect();
pred_count[START_BLOCK] += 1;
// We need a place to store the new blocks generated
......
......@@ -95,7 +95,7 @@ fn compute_basic_coverage_blocks(
let mut basic_blocks = Vec::new();
for (bb, data) in mir_cfg_without_unwind {
if let Some(last) = basic_blocks.last() {
let predecessors = &mir_body.predecessors()[bb];
let predecessors = &mir_body.basic_blocks.predecessors()[bb];
if predecessors.len() > 1 || !predecessors.contains(last) {
// The `bb` has more than one _incoming_ edge, and should start its own
// `BasicCoverageBlockData`. (Note, the `basic_blocks` vector does not yet
......
......@@ -133,7 +133,7 @@ fn find_local_assigned_to_return_place(
return local;
}
match body.predecessors()[block].as_slice() {
match body.basic_blocks.predecessors()[block].as_slice() {
&[pred] => block = pred,
_ => return None,
}
......
......@@ -61,7 +61,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
/// Returns the amount of blocks that were duplicated
pub fn separate_const_switch(body: &mut Body<'_>) -> usize {
let mut new_blocks: SmallVec<[(BasicBlock, BasicBlock); 6]> = SmallVec::new();
let predecessors = body.predecessors();
let predecessors = body.basic_blocks.predecessors();
'block_iter: for (block_id, block) in body.basic_blocks().iter_enumerated() {
if let TerminatorKind::SwitchInt {
discr: Operand::Copy(switch_place) | Operand::Move(switch_place),
......
......@@ -161,7 +161,7 @@ fn check_fn(
// `arg` is a reference as it is `.deref()`ed in the previous block.
// Look into the predecessor block and find out the source of deref.
let ps = &mir.predecessors()[bb];
let ps = &mir.basic_blocks.predecessors()[bb];
if ps.len() != 1 {
continue;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册