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:
@@ -269,7 +269,7 @@ fn extend_to_use(
|
||||
while let Some(livein) = worklist.pop() {
|
||||
// We've learned that the value needs to be live-in to the `livein` EBB.
|
||||
// Make sure it is also live at all predecessor branches to `livein`.
|
||||
for &(pred, branch) in cfg.get_predecessors(livein) {
|
||||
for (pred, branch) in cfg.pred_iter(livein) {
|
||||
if lr.extend_in_ebb(pred, branch, &func.layout) {
|
||||
// This predecessor EBB also became live-in. We need to process it later.
|
||||
worklist.push(pred);
|
||||
@@ -463,7 +463,7 @@ impl Liveness {
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
for &(_, pred_branch) in cfg.get_predecessors(succ_ebb) {
|
||||
for (_, pred_branch) in cfg.pred_iter(succ_ebb) {
|
||||
let pred_arg = func.dfg.inst_variable_args(pred_branch)[num];
|
||||
let pred_affinity = &mut self.ranges.get_mut(pred_arg).unwrap().affinity;
|
||||
if pred_affinity.is_none() {
|
||||
|
||||
Reference in New Issue
Block a user