diff options
| author | Cliff Click <cliffc@acm.org> | 2025-01-13 15:50:26 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-15 15:07:30 -0800 |
| commit | c3559bb04362b948c390b35cac622ce61f494238 (patch) | |
| tree | 21fbae485fb7c050c02887219ab38562e286b3fd /chapter18/src | |
| parent | 9191219b0f5904458b71e0ae7a6382d4c550d2ca (diff) | |
| download | Simple-c3559bb04362b948c390b35cac622ce61f494238.tar.gz Simple-c3559bb04362b948c390b35cac622ce61f494238.zip | |
Missing constant test
Diffstat (limited to 'chapter18/src')
3 files changed, 21 insertions, 2 deletions
diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/CallEndNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/CallEndNode.java index 48edc0eb..a2866d65 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/CallEndNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/CallEndNode.java @@ -50,6 +50,7 @@ public class CallEndNode extends CFGNode implements MultiNode { CallNode call = call(); Node fptr = call.fptr(); if( fptr.nOuts() == 1 && // Only user is this call + fptr instanceof ConstantNode && // Function is being called, and its not-null fptr._type instanceof TypeFunPtr tfp && tfp.notNull()) { ReturnNode ret = (ReturnNode)in(1); diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java index 64c07cf0..0e92c8c0 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -13,9 +13,9 @@ public class Chapter18Test { """ return 0; """); - code.parse().opto().typeCheck().GCM(); + code.parse().opto().typeCheck().GCM().localSched(); assertEquals("return 0;", code._stop.toString()); - assertEquals("0", Eval2.eval(code, 1)); + assertEquals("0", Eval2.eval(code, 2)); } @Test @@ -297,4 +297,20 @@ for(;;) { assertEquals("0", Eval2.eval(code, 0)); } + // Inline hidden called more than once + @Test + public void testInline() { + CodeGen code = new CodeGen( +""" +{int->int}?! i2i = {int i->return i;}; +{{int->int}->{int->int}}! f2f = {{int->int} f->return f;}; +val o = i2i; +if (arg) i2i = null; +if (i2i) return i2i(arg); +return f2f(o)(1); +"""); + code.parse().opto().typeCheck().GCM().localSched(); + assertEquals("Stop[ return Phi(Region,o( arg),o( 1)); return Parm_i(o,int,arg,1); ]", code._stop.toString()); + assertEquals("1", Eval2.eval(code, 2)); + } } diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java b/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java index 006034e9..913e21e9 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java @@ -137,6 +137,7 @@ public abstract class Eval2 { // Evaluate until exit or timeout. Each outer loop step computes // all data nodes under some new Control. while( true ) { + assert BB!=null; traceCtrl(BB,trace); if( trace!=null ) System.out.println(F.p()); @@ -165,6 +166,7 @@ public abstract class Eval2 { case RegionNode r : break; default: throw Utils.TODO(); } + assert !BB.isDead(); } } |
