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

Method kill

chapter14/src/main/java/com/seaofnodes/simple/node/Node.java:235–249  ·  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

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

Callers 11

iterateMethod · 0.95
idealizeMethod · 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