Expose CFG predecessors only as an iterator.
Define two public iterator types in the flowgraph module, PredIter and SuccIter, which are by-value iterators over an EBB's predecessors and successors respectively. Provide matching pred_iter() and succ_iter() methods for inspecting the CFG. Remove the get_predecessors() method which returned a slice. Update the uses of get_predecessors(), none of which depended on it being a slice. This abstraction makes it possible to change the internal representation of the CFG.
This commit is contained in:
@@ -102,7 +102,7 @@ impl<'a> CssaVerifier<'a> {
|
||||
fn check_cssa(&self) -> Result {
|
||||
for ebb in self.func.layout.ebbs() {
|
||||
let ebb_params = self.func.dfg.ebb_params(ebb);
|
||||
for &(_, pred) in self.cfg.get_predecessors(ebb) {
|
||||
for (_, 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!(
|
||||
|
||||
@@ -60,7 +60,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.get_predecessors(ebb) {
|
||||
for (pred, _) in self.cfg.pred_iter(ebb) {
|
||||
worklist.insert(pred);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,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.get_predecessors(ebb) {
|
||||
for (_, pred) in self.cfg.pred_iter(ebb) {
|
||||
if !self.live_at_use(lr, pred) {
|
||||
return err!(
|
||||
pred,
|
||||
|
||||
@@ -933,9 +933,8 @@ impl<'a> Verifier<'a> {
|
||||
return err!(ebb, "cfg had unexpected successor(s) {:?}", excess_succs);
|
||||
}
|
||||
|
||||
expected_preds.extend(self.expected_cfg.get_predecessors(ebb).iter().map(|&(_,
|
||||
inst)| inst));
|
||||
got_preds.extend(cfg.get_predecessors(ebb).iter().map(|&(_, inst)| inst));
|
||||
expected_preds.extend(self.expected_cfg.pred_iter(ebb).map(|(_, inst)| inst));
|
||||
got_preds.extend(cfg.pred_iter(ebb).map(|(_, inst)| inst));
|
||||
|
||||
let missing_preds: Vec<Inst> = expected_preds.difference(&got_preds).cloned().collect();
|
||||
if !missing_preds.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user