From 3a3d469154846b648b09c708bfe3e8c16a203654 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 13 Jan 2025 15:09:59 -0800 Subject: Some dead inf call bug fixes More comments about meeting nil above the center line falls - but does not (can not) dual. This implies have TFPs with *no* allowed functions that are below centerline; if allowed null then its basically an alternate null. If not allowed null and not allowed any functions, its basically a high value (not executable). IfNode folds. Do not remove a dead infinite loop - it needs to remain as a CFG sink. --- .../test/java/com/seaofnodes/simple/Chapter18Test.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'chapter18/src/test/java') diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java index 217c6275..3fc5c8de 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -115,7 +115,7 @@ var fcn = arg ? { int x -> x*x; } : { int x -> x+x; }; return fcn(3); """); code.parse().opto(); - assertEquals("Stop[ return Phi(Region,{ int -> int #1},{ int -> int #2})( 3); return (Parm_x($fun,int)*x); return (Parm_x($fun,int)*2); ]", code._stop.toString()); + assertEquals("Stop[ return Phi(Region,{ int -> int #1},{ int -> int #2})( 3); return (Parm_x($fun,int,3)*x); return (Parm_x($fun,int,3)*2); ]", code._stop.toString()); assertEquals("6", Eval2.eval(code, 0)); assertEquals("9", Eval2.eval(code, 1)); } @@ -180,6 +180,22 @@ for(;;) { } + @Test + public void testFcn9() { + CodeGen code = new CodeGen( +""" +{int -> int}? i2i = null; +for(;;) { + if (i2i) return i2i(arg); + var x = {int i-> return i;}; + arg = x(3); +} +"""); + code.parse().opto().typeCheck().GCM().localSched(); + assertEquals("Stop[ ]", code._stop.toString()); + assertEquals("0", Eval2.eval(code, 0)); + } + // Function break @Test public void testErr1() { -- cgit v1.2.3