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:
@@ -53,7 +53,7 @@ pub fn simple_legalize(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa:
|
||||
while let Some(_block) = pos.next_block() {
|
||||
let mut prev_pos = pos.position();
|
||||
while let Some(inst) = pos.next_inst() {
|
||||
match pos.func.dfg[inst] {
|
||||
match pos.func.dfg.insts[inst] {
|
||||
// control flow
|
||||
InstructionData::CondTrap {
|
||||
opcode:
|
||||
|
||||
Reference in New Issue
Block a user