Promote the BasicBlock tuple to a real struct;

It makes reading code that uses it easier to understand.
This commit is contained in:
Benjamin Bouvier
2018-07-19 15:29:29 +02:00
committed by Dan Gohman
parent ce177d643e
commit f72ff791b4
12 changed files with 127 additions and 50 deletions

View File

@@ -2,7 +2,7 @@
use dbg::DisplayList;
use dominator_tree::{DominatorTree, DominatorTreePreorder};
use flowgraph::ControlFlowGraph;
use flowgraph::{BasicBlock, ControlFlowGraph};
use ir::{ExpandedProgramPoint, Function};
use regalloc::liveness::Liveness;
use regalloc::virtregs::VirtRegs;
@@ -138,7 +138,7 @@ impl<'a> CssaVerifier<'a> {
fn check_cssa(&self) -> VerifierResult<()> {
for ebb in self.func.layout.ebbs() {
let ebb_params = self.func.dfg.ebb_params(ebb);
for (_, pred) in self.cfg.pred_iter(ebb) {
for BasicBlock { inst: pred, .. } in self.cfg.pred_iter(ebb) {
let pred_args = self.func.dfg.inst_variable_args(pred);
// This should have been caught by an earlier verifier pass.
assert_eq!(

View File

@@ -1,7 +1,7 @@
//! Verify CPU flags values.
use entity::{EntityMap, SparseSet};
use flowgraph::ControlFlowGraph;
use flowgraph::{BasicBlock, ControlFlowGraph};
use ir;
use ir::instructions::BranchInfo;
use isa;
@@ -61,7 +61,7 @@ impl<'a> FlagsVerifier<'a> {
// Revisit any predecessor blocks the first time we see a live-in for `ebb`.
None => {
self.livein[ebb] = value.into();
for (pred, _) in self.cfg.pred_iter(ebb) {
for BasicBlock { ebb: pred, .. } in self.cfg.pred_iter(ebb) {
worklist.insert(pred);
}
}

View File

@@ -1,6 +1,6 @@
//! Liveness verifier.
use flowgraph::ControlFlowGraph;
use flowgraph::{BasicBlock, ControlFlowGraph};
use ir::entities::AnyEntity;
use ir::{ExpandedProgramPoint, Function, Inst, ProgramOrder, ProgramPoint, Value};
use isa::TargetIsa;
@@ -194,7 +194,7 @@ impl<'a> LivenessVerifier<'a> {
// Check all the EBBs in the interval independently.
loop {
// If `val` is live-in at `ebb`, it must be live at all the predecessors.
for (_, pred) in self.cfg.pred_iter(ebb) {
for BasicBlock { inst: pred, .. } in self.cfg.pred_iter(ebb) {
if !self.live_at_use(lr, pred) {
return err!(
pred,

View File

@@ -60,7 +60,7 @@ use self::flags::verify_flags;
use dbg::DisplayList;
use dominator_tree::DominatorTree;
use entity::SparseSet;
use flowgraph::ControlFlowGraph;
use flowgraph::{BasicBlock, ControlFlowGraph};
use ir;
use ir::entities::AnyEntity;
use ir::instructions::{BranchInfo, CallInfo, InstructionFormat, ResolvedConstraint};
@@ -990,8 +990,12 @@ impl<'a> Verifier<'a> {
return err!(ebb, "cfg had unexpected successor(s) {:?}", excess_succs);
}
expected_preds.extend(self.expected_cfg.pred_iter(ebb).map(|(_, inst)| inst));
got_preds.extend(cfg.pred_iter(ebb).map(|(_, inst)| inst));
expected_preds.extend(
self.expected_cfg
.pred_iter(ebb)
.map(|BasicBlock { inst, .. }| inst),
);
got_preds.extend(cfg.pred_iter(ebb).map(|BasicBlock { inst, .. }| inst));
let missing_preds: Vec<Inst> = expected_preds.difference(&got_preds).cloned().collect();
if !missing_preds.is_empty() {