diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-27 09:09:23 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-27 09:09:23 -0700 |
| commit | 3d226b49e1cd23b41fd9baf3917f751973c1ad11 (patch) | |
| tree | 5c59f2b2de102c1089e71e29f59c71357d3b5512 | |
| parent | 5f85f435aeece40e2c0770f89d7642f9af718531 (diff) | |
| download | Simple-3d226b49e1cd23b41fd9baf3917f751973c1ad11.tar.gz Simple-3d226b49e1cd23b41fd9baf3917f751973c1ad11.zip | |
minor fixes
Fix CI build
Backport ch 23 fix to ch 22.
9 files changed, 16 insertions, 41 deletions
diff --git a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java index c7de06df..9a7dda5d 100644 --- a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -29,15 +29,6 @@ public class Chapter03Test { } @Test - public void testVarScopeNoPeephole() { - Parser parser = new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b; } return c;"); - Node._disablePeephole = true; - ReturnNode ret = parser.parse(); - Node._disablePeephole = false; - assertEquals("return (1+3);", ret.print()); - } - - @Test public void testVarDist() { Parser parser = new Parser("int x0=1; int y0=2; int x1=3; int y1=4; return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1);"); ReturnNode ret = parser.parse(); diff --git a/chapter04/src/main/java/com/seaofnodes/simple/node/Node.java b/chapter04/src/main/java/com/seaofnodes/simple/node/Node.java index 4f196805..fdde869b 100644 --- a/chapter04/src/main/java/com/seaofnodes/simple/node/Node.java +++ b/chapter04/src/main/java/com/seaofnodes/simple/node/Node.java @@ -1,9 +1,8 @@ package com.seaofnodes.simple.node; -import com.seaofnodes.simple.Utils; import com.seaofnodes.simple.Parser; +import com.seaofnodes.simple.Utils; import com.seaofnodes.simple.type.Type; - import java.util.*; /** diff --git a/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java index 38c9c00d..46b1ca33 100644 --- a/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -30,15 +30,6 @@ public class Chapter03Test { } @Test - public void testVarScopeNoPeephole() { - Parser parser = new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b; } return c;"); - Node._disablePeephole = true; - ReturnNode ret = parser.parse(); - Node._disablePeephole = false; - assertEquals("return (1+3);", ret.print()); - } - - @Test public void testVarDist() { Parser parser = new Parser("int x0=1; int y0=2; int x1=3; int y1=4; return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1);"); ReturnNode ret = parser.parse(); diff --git a/chapter05/src/main/java/com/seaofnodes/simple/node/Node.java b/chapter05/src/main/java/com/seaofnodes/simple/node/Node.java index 8c155447..e17d7b9a 100644 --- a/chapter05/src/main/java/com/seaofnodes/simple/node/Node.java +++ b/chapter05/src/main/java/com/seaofnodes/simple/node/Node.java @@ -1,10 +1,8 @@ package com.seaofnodes.simple.node; import com.seaofnodes.simple.Parser; - import com.seaofnodes.simple.Utils; import com.seaofnodes.simple.type.Type; - import java.util.*; /** diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java index 10b67f5f..c3cd43c3 100644 --- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -30,15 +30,6 @@ public class Chapter03Test { } @Test - public void testVarScopeNoPeephole() { - Parser parser = new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b; } return c;"); - Node._disablePeephole = true; - StopNode ret = parser.parse(); - Node._disablePeephole = false; - assertEquals("return (1+3);", ret.print()); - } - - @Test public void testVarDist() { Parser parser = new Parser("int x0=1; int y0=2; int x1=3; int y1=4; return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1);"); StopNode ret = parser.parse(); diff --git a/chapter22/src/main/java/com/seaofnodes/simple/Parser.java b/chapter22/src/main/java/com/seaofnodes/simple/Parser.java index 72fe6a71..087fd1fd 100644 --- a/chapter22/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter22/src/main/java/com/seaofnodes/simple/Parser.java @@ -236,8 +236,13 @@ public class Parser { last = parseStatement(); // Last expression is the return except for the top-level main - if( ctrl()._type==Type.CONTROL && fun.sig() != _code._main ) - fun.addReturn(ctrl(), _scope.mem().merge(), last); + if( ctrl()._type==Type.CONTROL ) + if( fun.sig() != _code._main ) + fun.addReturn(ctrl(), _scope.mem().merge(), last); + else { + fun.setDef(1,XCTRL); // Kill default main + _code.addAll(fun._outputs); + } // Pop off the inProgress node on the multi-exit Region merge assert r.inProgress(); diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter09Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter09Test.java index d4d02aa9..551880b1 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter09Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter09Test.java @@ -128,7 +128,7 @@ while(v1+arg) { } """); code.parse().opto(); - assertEquals("return Top;", code.print()); + assertEquals("Stop[ ]", code.print()); // No explicit return: omit default main. } @Test @@ -210,7 +210,7 @@ return -0+0+0; public void testFuzz3() { CodeGen code = new CodeGen("int v0=0; while(0==69) while(v0) return 0;"); code.parse().opto(); - assertEquals("return 0;", code.print()); + assertEquals("Stop[ ]", code.print()); // The only return is unreachable. } @Test diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter20Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter20Test.java index 1765512a..1f4a3d27 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter20Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter20Test.java @@ -205,6 +205,11 @@ s.cs[0] = 67; // C s.cs[1] = 108; // l hashCode(s); """; + // Without an explicit return, default main must be removed completely. + // Seed 0 previously left a loop with a missing branch successor. + for( String cpu : new String[]{"x86_64_v2","riscv","arm"} ) + new CodeGen(src,com.seaofnodes.simple.type.TypeInteger.BOT,0) + .driver(CodeGen.Phase.Encoding,cpu,"SystemV"); testTarget(src,"x86_64_v2", "SystemV",0,null); testTarget(src,"riscv" , "SystemV",0,null); testTarget(src,"arm" , "SystemV",0,null); diff --git a/docs/chapter-backports.md b/docs/chapter-backports.md index 517805bd..7d383478 100644 --- a/docs/chapter-backports.md +++ b/docs/chapter-backports.md @@ -28,12 +28,6 @@ renumbering chapters is deferred. addresses. Do not enlarge relocation arrays or add an interim address scan. Validate returned pointers by calling them, including library pointers, while still deleting genuinely unused helpers. Keep module/escape machinery in 25. -- **Chapter 22 String without an explicit return.** The unchanged source in - `Chapter20Test.testString` fails before allocation in loop-tree construction - or GCM at the historically tested seeds 0-29, on all targets. The original - snapshot has the same failures; seed 123 folds the work away. Reduce default - return/dead-call handling. A new return or a different seed is not a fix; - this historical sweep is not a reason to sweep routine backend tests. - **Chapter 25 null-dereference diagnostic.** This setup was accepted despite dereferencing null on the taken arm; investigate separately from B13: @@ -198,6 +192,7 @@ Unresolved reproductions have been promoted to the pending queue above. | Completed work | Scope and evidence retained | |---|---| +| Chapter 22 String without an explicit return | Backported 23's default-main teardown: when top-level control falls through, replace main's Start input with XCTRL and queue its users. Previously 22 omitted the return while retaining live control, leaving loop fragments with missing exits. Current seed 0 reproduced a missing-successor failure in Encoding; the earlier GCM changes had moved it past the originally recorded failure. The unchanged `Chapter20Test.testString` now also checks seed 0 through Encoding on x86/RISC-V/ARM, preserving its existing seed-123 allocator checks. Two Chapter09Test graph expectations now reflect removal of a default main with no live return; their sources are unchanged. Baseline and final full Chapter 22 suites passed (425 tests plus fuzzer), logged in `build/string-baseline.log` and `build/string-final.log`. Chapters 23-24 already contain this teardown; no later compiler changes were needed. | | Infinite-loop evaluation | Eval2 now runs the missing loop-tree phase in 21 and explicitly follows NeverNode projection 0 in 21-25. Existing `testFcn9` expects timeout in 21-24. Full 18-25 Make suites passed on 2026-09-26 (`build/never-exit-tests.log` and `build/never-exit-final.log`). On 2026-09-27, Cliff requested removal of the frozen-source fixture, replay tests, related reductions, and seed-list entry as unnecessary test overhead; the evaluator fixes remain. | | Always-on peepholes | Removed the global disable flag and branches in 2-18, the Chapter 18 parse overload, test toggles, and transpiler metadata/Rust output. Updated early graph expectations and READMEs; removed duplicate no-peephole scope tests. Chapter 8 fuzzing checks compilation/evaluation for failures; 9-18 compare worklist seeds 123/456 like later chapters. The Chapter 18 Load type workaround was unnecessary with normal forwarding and was removed. All 1-25 default Make suites passed across `build/always-peeps-tests.log` and `build/always-peeps-final.log`; later evaluator corrections are recorded above. The baseline was green in `build/always-peeps-baseline.log`. Direct checks exercised both worklist seeds in 9-18. The transpiler compiles and its focused grammar/Rust-output check passes; its existing repository-wide test stops at source-free chapter00 with `no source files`. | | B10 and integer/constant-array widening | Widening starts in 24. Both 24-25 now use levels 0-3, dual widening `3-widen`, retained singleton widening, and widening on TypeConAry. `nonZero` preserves the coordinate. The same TypeTest regression and integer gather ranges run in both snapshots; before the backport, Chapter 24 fails the widening regression and lattice associativity. Loop Phis widen only below-center nonconstant ranges: widening an above-center range to level 1 then falling to zero at level 0 violated SCCP monotonicity in 24's existing `testCloneAnd` and `testInfinite`; both now pass, with the guard also in 25. | |
