From fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 22 Sep 2026 15:50:22 -0700 Subject: Graph cleanup Phis stay with regions, stop sinks to bottom, --- chapter25/src/main/java/com/seaofnodes/simple/Parser.java | 3 ++- .../src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'chapter25/src/main/java') diff --git a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java index ffd8bf64..05685418 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java @@ -778,6 +778,7 @@ public class Parser { // In if true branch, the ifT proj node becomes the ctrl // But first clone the scope and set it as current ScopeNode fScope = _scope.dup(); // Duplicate current scope + fScope.ctrl(ifF); // The pending arm already starts at False _xScopes.push(fScope); // For graph visualization we need all scopes // Parse the true side @@ -803,7 +804,7 @@ public class Parser { // Parse the false side _scope = fScope; // Restore scope, then parse else block if any - ctrl(ifF.unkeep()); // Ctrl token is now set to ifFalse projection + ifF.unkeep(); // fScope already owns the false control // Up-cast predicate, even if not else clause, because predicate can // remain true if the true clause exits: `if( !ptr ) return 0; return ptr.fld;` _scope.addGuards(ifF,pred,true); diff --git a/chapter25/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/chapter25/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java index e9b1dc6d..506ac3e2 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java @@ -38,8 +38,9 @@ public class SimpleGraphAdapter extends GraphAdapter { } private Kind kind(Node n) { + if( n instanceof StopNode ) return Kind.STOP; if( n instanceof ScopeNode ) return Kind.SCOPE; - if( n instanceof StartCUNode || n instanceof StopCUNode ) return Kind.UNIT; + if( n instanceof StartCUNode ) return Kind.UNIT; if( n instanceof FunNode ) return Kind.FUN; // Start inherits Loop for whole-program analysis, but is not a source loop. if( n instanceof StartNode ) return Kind.CTRL; -- cgit v1.2.3