MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / kill

Method kill

chapter13/src/main/java/com/seaofnodes/simple/node/Node.java:237–251  ·  view source on GitHub ↗

Kill a Node with no uses , by setting all of its defs to null. This may recursively kill more Nodes, and is basically dead code elimination.

( )

Source from the content-addressed store, hash-verified

235 * code elimination.
236 */
237 public void kill( ) {
238 unlock();
239 moveDepsToWorklist();
240 assert isUnused(); // Has no uses, so it is dead
241 _type=null; // Flag as dead
242 while( nIns()>0 ) { // Set all inputs to null, recursively killing unused Nodes
243 Node old_def = _inputs.removeLast();
244 if( old_def != null ) {
245 IterPeeps.add(old_def);// Revisit neighbor because removed use
246 if( old_def.delUse(this) ) // If we removed the last use, the old def is now dead
247 old_def.kill(); // Kill old def
248 }
249 }
250 assert isDead(); // Really dead now
251 }
252
253 // Mostly used for asserts and printing.
254 public boolean isDead() { return isUnused() && nIns()==0 && _type==null; }

Callers 10

iterateMethod · 0.95
setDefMethod · 0.95
delDefMethod · 0.95
popNMethod · 0.95
subsumeMethod · 0.95
deadCodeElimMethod · 0.95
widenMethod · 0.95
parseWhileMethod · 0.45
mergeScopesMethod · 0.45
endLoopMethod · 0.45

Calls 8

unlockMethod · 0.95
moveDepsToWorklistMethod · 0.95
isUnusedMethod · 0.95
nInsMethod · 0.95
addMethod · 0.95
delUseMethod · 0.95
isDeadMethod · 0.95
removeLastMethod · 0.45

Tested by

no test coverage detected