Change a def into a Node. Keeps the edges correct, by removing the corresponding use->def edge. This may make the original def go dead. This function is co-recursive with #kill. This method is the normal path for altering a Node, because it does the proper d
(int idx, N new_def )
| 166 | * @return new_def for flow coding |
| 167 | */ |
| 168 | public <N extends Node> N setDef(int idx, N new_def ) { |
| 169 | unlock(); |
| 170 | Node old_def = in(idx); |
| 171 | if( old_def == new_def ) return new_def; // No change |
| 172 | // If new def is not null, add the corresponding def->use edge |
| 173 | // This needs to happen before removing the old node's def->use edge as |
| 174 | // the new_def might get killed if the old node kills it recursively. |
| 175 | if( new_def != null ) |
| 176 | new_def.addUse(this); |
| 177 | // Set the new_def over the old (killed) edge |
| 178 | _inputs.set(idx,new_def); |
| 179 | if( old_def != null ) { // If the old def exists, remove a def->use edge |
| 180 | if( old_def.delUse(this) ) // If we removed the last use, the old def is now dead |
| 181 | old_def.kill(); // Kill old def |
| 182 | else CODE.add(old_def); // Else old lost a use, so onto worklist |
| 183 | } |
| 184 | moveDepsToWorklist(); |
| 185 | // Return new_def for easy flow-coding |
| 186 | return new_def; |
| 187 | } |
| 188 | public <N extends Node> N setDefX(int idx, N new_def ) { |
| 189 | while( nIns() <= idx ) addDef(null); |
| 190 | return setDef(idx,new_def); |
no test coverage detected