From d5770b4022c35e069fca9b8ba42c163b70b9de27 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 14 Jan 2025 09:35:56 -0800 Subject: 2 more fuzzer bugs --- .../src/main/java/com/seaofnodes/simple/Parser.java | 2 ++ .../main/java/com/seaofnodes/simple/node/LoopNode.java | 17 ----------------- .../java/com/seaofnodes/simple/node/RegionNode.java | 13 +++++++++---- 3 files changed, 11 insertions(+), 21 deletions(-) (limited to 'chapter18/src/main/java/com') diff --git a/chapter18/src/main/java/com/seaofnodes/simple/Parser.java b/chapter18/src/main/java/com/seaofnodes/simple/Parser.java index 4f19dda2..03ae978a 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/Parser.java @@ -1301,6 +1301,7 @@ public class Parser { if( matchx("++") || matchx("--") ) { if( f._final && !f._fname.equals("[]") ) throw error("Cannot reassign final '"+f._fname+"'"); + load.keep(); int delta = _lexer.peek(-1)=='+' ? 1 : -1; // Pre vs post Node val = f._type instanceof TypeFloat ? peep(new AddFNode(load,con(TypeFloat.constant(delta)))) @@ -1311,6 +1312,7 @@ public class Parser { // done via the type system. if( base.isAry() ) st.setDef(0,ctrl()); memAlias(f._alias, peep(st)); + load.unkeep(); // And use the original loaded value as the result } else expr.unkill(); off.unkill(); diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/LoopNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/LoopNode.java index a31c8ac8..f70a1012 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/LoopNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/LoopNode.java @@ -23,23 +23,6 @@ public class LoopNode extends RegionNode { return entry()._type; } - @Override - public Node idealize() { - if( inProgress() ) return null; - // Dead infinite loops with NO control flow out stick around - as a - // dead infinite loop, to signal that control stops and spins here. - if( nIns()==2 && !hasPhi() && !hasCFG() ) - return null; - return super.idealize(); - } - - private boolean hasCFG() { - for( Node phi : _outputs ) - if( phi instanceof CFGNode ) - return true; - return false; - } - // Bypass Region idom, same as the default idom() using use in(1) instead of in(0) @Override public int idepth() { return _idepth==0 ? (_idepth=idom().idepth()+1) : _idepth; } // Bypass Region idom, same as the default idom() using use in(1) instead of in(0) diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java index d8e24964..ea053c02 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java @@ -68,13 +68,18 @@ public class RegionNode extends CFGNode { return in(1); // Collapse if no Phis; 1-input Phis will collapse on their own // If a CFG diamond with no merging, delete: "if( pred ) {} else {};" - if( !_disablePeephole && - !hasPhi() && // No Phi users, just a control user + if( !_disablePeephole && // Optional + !hasPhi() && // No Phi users, just a control user in(1) instanceof CProjNode p1 && in(2) instanceof CProjNode p2 && p1.in(0).addDep(this)==p2.in(0).addDep(this) && - p1.in(0) instanceof IfNode iff ) - return iff.ctrl(); + p1.in(0) instanceof IfNode iff ) { + // Replace with the iff.ctrl directly + if( nIns()==3 ) return iff.ctrl(); + // Just delete the path for fat Regions + setDef(1,iff.ctrl()); + return delDef(2); + } return null; } -- cgit v1.2.3