Clean up repairable
- Clean up the prototype repairable / function editor implementation done by @xrouth2.
- Core interface is
edit
method on a FunctionEditor struct, which contains a &mut Function.edit
takes a closure that implements a single edit on the function.edit
is passed a FunctionEdit, on which there are methodsdelete_node
,add_node
, andreplace_all_uses_with
. Per-edit
, an entry is added to a list internal to the FunctionEditor containing each edit, where one edit contains a deleted node set and an added node set.- The FunctionEditor also contains a mutable def_use map that it incrementally updates based off of replace_all_uses_with. This def_use map is available to use by passes.
- Each transformation is passed a FunctionEditor, on which it accumulates edits to the function using
edit
. After the transformation, the pass manager 1. uses the edit list to repair partitions and debug info and 2. recompacts node IDs by deleting gravestone nodes and updating side data structures containing node IDs (partitions and debug info) - Partitions are repaired in the following way:
- Collapse all of the edits in the edit list into a single edit
- Compute the reverse postorder of the function, and assign added nodes to partitions in order that they're in the rev po - this logic is per-node specific
- Delete deleted nodes from partitions
- Closes #3 (closed)
Edited by rarbore2