Make DataFlowGraph::insts public, but restricted (#5450)
We have some operations defined on DataFlowGraph purely to work around borrow-checker issues with InstructionData and other data on DataFlowGraph. Part of the problem is that indexing the DFG directly hides the fact that we're only indexing the insts field of the DFG. This PR makes the insts field of the DFG public, but wraps it in a newtype that only allows indexing. This means that the borrow checker is better able to tell when operations on memory held by the DFG won't conflict, which comes up frequently when mutating ValueLists held by InstructionData.
This commit is contained in:
@@ -232,7 +232,7 @@ pub fn do_remove_constant_phis(func: &mut Function, domtree: &mut DominatorTree)
|
||||
let mut summary = BlockSummary::new(&bump, formals);
|
||||
|
||||
for inst in func.layout.block_insts(b) {
|
||||
let idetails = &func.dfg[inst];
|
||||
let idetails = &func.dfg.insts[inst];
|
||||
// Note that multi-dest transfers (i.e., branch tables) don't
|
||||
// carry parameters in our IR, so we only have to care about
|
||||
// `SingleDest` here.
|
||||
@@ -378,9 +378,9 @@ pub fn do_remove_constant_phis(func: &mut Function, domtree: &mut DominatorTree)
|
||||
continue;
|
||||
}
|
||||
|
||||
let old_actuals = func.dfg[edge.inst].take_value_list().unwrap();
|
||||
let old_actuals = func.dfg.insts[edge.inst].value_list().unwrap();
|
||||
let num_old_actuals = old_actuals.len(&func.dfg.value_lists);
|
||||
let num_fixed_actuals = func.dfg[edge.inst]
|
||||
let num_fixed_actuals = func.dfg.insts[edge.inst]
|
||||
.opcode()
|
||||
.constraints()
|
||||
.num_fixed_value_arguments();
|
||||
@@ -412,7 +412,7 @@ pub fn do_remove_constant_phis(func: &mut Function, domtree: &mut DominatorTree)
|
||||
new_actuals.push(actual_i, &mut func.dfg.value_lists);
|
||||
}
|
||||
}
|
||||
func.dfg[edge.inst].put_value_list(new_actuals);
|
||||
*func.dfg.insts[edge.inst].value_list_mut().unwrap() = new_actuals;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user