cgen: B5-c1 helper+funnel single peels fold into type_chase_named — 19 sites, cs-only
The exact F2b c1 set (rob next-arc spec + B5 re-rule): node_tuplearg:249, fld_issigned:409, castsrcprim:501/:531, struct_float_class:598, tagged_arg_size:640, tagged_memarg_size:661, type_isnullable:740, nullable_ptr_tag:750, cg_tagged_success_tag:860, cg_variant_is_error:876, cg_tag_for_variant:899, type_istagged:953, type_unwrap:1269 + the widen/ fill funnel entries cg_widen_tagged_store:2456/:2480/:2483, cg_widen_tagged_push:2905, cg_structlit_fill:3195. Raw `->under` in cgen.c 88→69. Riding per re-rule R1: peel-ok-#218 annotations at cg_variant_match/cg_variant_struct_match (citing ken's b5 oracle §4 — chasing those four peels graduates zero v2_struct rows; the real fix is a both-stage NAMED-source arm, task #95) and the :755 peel-ok annotation mirroring ww cgenutil.ww:2758 (probe-cleared,018ef66). :447 untouched (c2's grant). TRAIN INVARIANT: cs-only — zero selfhost/ or lib/ bytes move; w6c_ww/ ww_ww/w6a_ww/w6l_ww bit-identical to thebcd948dbaselines (md5 28ad889042bad8006f1997cbcec94805 / 4e9ca8741f19e1f68219ff799a5e5a14). cs movers bounded to exactly: kb5_targ, kb5_tmem, kb5_wpush, kb5_null, kb5_f32p, kb5_fill2, kb5_tuparg_c; five selfhost mains + the rest of the kb2/kb3/kb4/kb5/kna corpus byte-NEUTRAL both stages. LIVE graduations: kb5_targ (tagged_arg_size sized a 2-level alias union param 0 → wrong arg path, cs silent exit 1) and kb5_tmem (>48B memarg twin) → 0/0 byte-id. Divergence flips to byte-id: wpush/null/f32p. #85 CLOSES as SITE-CLOSURE with ZERO live graduations: type_unwrap's two consumers (:14716/:14907, both tuple-global layout walks that want the chased view) are checker-DEAD on cs for alias tuples (#86 upstream) — correctness there is by-construction, pinned by tupglobal_bound86. DESIGNED DIVERGENCE (re-rule R4, task #100): the :3195 chase flips kb5_fill2 from both-wrong-IDENTICAL-silent (gate-blind, both stages accepted and ran wrong byte-identically) to cs-LOUD / ww-silent-wrong. A loud, disclosed, pinned divergence over a silent miscompile; rejected programs emit no asm so the byte-id gates hold. Dual-cell pin (fill2_bound100): cs experr + ww run-exit-1 both asserted; fill0 both-loud control holds. #100 (the ww twin gate) fires immediately after B5 so the window is one train wide. Oracle corrections at the c1 boundary (ken c1-BOUNDARY ADDENDUM, verified on his independent scratch build; rob ack'd, scope unchanged): C1-CORR-1: kb5_succ does NOT flip here — its residual divergence is exactly three paired return-position tag syntheses, the cgreturn return-route family (:12278/:12318/:12322). Joins c3's graduation set; pinned succ_bound_c3 K_RUN_NOID until then. C1-CORR-2 (corrects re-rule R2): kb5_wstore_a does NOT flip — the ident-lhs N_ASSIGN tagged store gates in the cgexpr INLINE set (B6), never reaching the :2456 funnel; cs byte-neutral here. Pinned wstore_a_bound_b6 K_RUN_NOID; byte-id rides B6. C1-CORR-3 (corrects re-rule R3 + ken FLAG-2): the :249 chase is NOT purely latent — the CAST spelling (kb5_tuparg_c) earned a LIVE cs graduation (cs ok/1 → ok/0, correct tuple-arg classify); ww still runs wrong (task #99). Two-key pin tuparg_cast_bound99: cs-0 earned + ww-1 pinned observed-wrong; byte-id re-pins to full 0/0 when #99's ww fix lands. New 944_alias_cgen_b5_run row table (16 rows, 40 checks): controls signed/wstore/wstore1 byte-NEUTRAL as predicted (kind-keyed tests are the only behavior-visible peels — type.c classifiers already recurse); literal tuparg spellings stay dual-cell bounds (#99/#86). All 944-family suites green; sizelint 0.
This commit is contained in:
522
test/wcc/944_alias_cgen_b5_run.c
Normal file
522
test/wcc/944_alias_cgen_b5_run.c
Normal file
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* 944_alias_cgen_b5_run — #5 alias arc F2b (B5 train): cstage cgen
|
||||
* helper + funnel internalization through type_chase_named (c1), the
|
||||
* #73 tripwire graduation (c2), the #89 cgreturn return-position widen
|
||||
* (c3) and the #93 deref-index pointee chase (c4). All cs-only: every
|
||||
* graduation is a DIVERGE→byte-id flip (cs aligns UP to ww's already-
|
||||
* chasing asm); zero selfhost/lib bytes move across the train, so the
|
||||
* _ww binaries stay bit-identical (the crossing detector).
|
||||
*
|
||||
* Row sources are ken's B5 oracle probes (/tmp/ken_b5/src,
|
||||
* .ai/ken-b5-oracle.md + its c1-BOUNDARY ADDENDUM) and the c3/c4
|
||||
* seeds (/tmp/ken_na, kb4).
|
||||
*
|
||||
* row | shape (oracle row) | cs/ww
|
||||
* --------------------+-------------------------------------+------
|
||||
* signed_ctl | kb5_signed: 2-lvl alias i8 field |
|
||||
* | load (fld_issigned) — classifiers |
|
||||
* | recurse, NO-mover control | 0/0
|
||||
* targ_2lvl | kb5_targ: 2-lvl alias (void|i64) |
|
||||
* | param ≤48B (tagged_arg_size) — was |
|
||||
* | cs LIVE exit-1, c1 graduation | 0/0
|
||||
* tmem_2lvl | kb5_tmem: >48B memarg twin |
|
||||
* | (tagged_memarg_size) — graduation | 0/0
|
||||
* wpush_2lvl | kb5_wpush: call-site widen, literal |
|
||||
* | arg (:2905 du) — divergence flip | 0/0
|
||||
* wstore_2lvl/_1lvl | kb5_wstore/wstore1: let-route |
|
||||
* | controls (du arrives chased |
|
||||
* | upstream — ken FLAG-1), NEUTRAL | 0/0
|
||||
* wstore_a_bound_b6 | kb5_wstore_a: ASSIGN-route re-store |
|
||||
* | — both-correct divergent; the |
|
||||
* | ident-lhs N_ASSIGN gates in the |
|
||||
* | cgexpr INLINE set (B6), NOT the |
|
||||
* | :2456 funnel (C1-CORR-2, corrects |
|
||||
* | rob R2) — byte-id waived until B6 | 0/0
|
||||
* succ_bound_c3 | kb5_succ: `?`-success remap over |
|
||||
* | 2-lvl alias result — both-correct |
|
||||
* | divergent at RETURN positions only |
|
||||
* | (:12278/:12318/:12322 family, |
|
||||
* | C1-CORR-1) — joins c3's graduation |
|
||||
* | set; byte-id waived until c3 | 0/0
|
||||
* null_2lvl | kb5_null: nullable fold + deref |
|
||||
* | (type_isnullable/nullable_ptr_tag) |
|
||||
* | — divergence flip | 0/0
|
||||
* f32p_2lvl | kb5_f32p: nested 2-lvl-alias f64 |
|
||||
* | field struct param |
|
||||
* | (struct_float_class) — flip | 0/0
|
||||
* fill0_ctl | kb5_fill0: named-struct array elem |
|
||||
* | in struct lit — LOUD both stages |
|
||||
* | (twin texts share the experr) | err/err
|
||||
* fill2_bound100 | kb5_fill2: 1-alias-lvl elem — was |
|
||||
* | both-wrong-IDENTICAL gate-blind; c1 |
|
||||
* | :3195 chase flips cs LOUD, ww stays |
|
||||
* | silent-wrong exit 1. DESIGNED |
|
||||
* | DIVERGENCE until the ww twin gate |
|
||||
* | (task #100) lands — dual-cell pin | err/1
|
||||
* tuparg_bound99 / | kb5_tuparg(1): literal named-tuple |
|
||||
* tuparg1_bound99 | arg — cs checker-rejects (#86-kin), |
|
||||
* | WW RUNS WRONG exit 1 (task #99, |
|
||||
* | metric-1 ww side). Dual-cell pin | err/1
|
||||
* tuparg_cast_bound99 | kb5_tuparg_c: cast spelling dodges |
|
||||
* | the cs checker; the :249 chase made |
|
||||
* | cs run CORRECT (LIVE c1 graduation, |
|
||||
* | C1-CORR-3 — corrects rob R3 + ken |
|
||||
* | FLAG-2); ww still WRONG exit 1 |
|
||||
* | (#99). Two-key pin: cs-0 earned + |
|
||||
* | ww-1 pinned-wrong; byte-id waived |
|
||||
* | until #99 re-pins to full byte-id | 0/1
|
||||
* tupglobal_bound86 | kb5_tupglobal: alias-tuple global — |
|
||||
* | cs checker-dead (#86), ww runs 0. |
|
||||
* | #85 type_unwrap close is SITE- |
|
||||
* | closure with zero live graduations |
|
||||
* | — this row pins the bound | err/0
|
||||
*
|
||||
* K_RUN rows build+run BOTH drivers (cs exit==cswant, ww exit==wwwant)
|
||||
* and assert cstage/wwstage asm byte-id. K_RUN_NOID asserts both run
|
||||
* cells but waives byte-id — cite the blocking task/commit at the row.
|
||||
* K_CSERR_WWRUN is the dual-cell bound kind (the inverse of
|
||||
* 944_alias_accept_run's K_RUN_CS_WWERR): the cstage build must FAIL
|
||||
* with experr AND the wwstage build+run must exit wwwant — both cells
|
||||
* asserted so neither the cs loudness nor the ww behavior can drift
|
||||
* silently while the cited task is parked. NNN<950, self-contained
|
||||
* /tmp sources, no imports (944 precedent).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int
|
||||
runwait(const char *cmd)
|
||||
{
|
||||
int rc = system(cmd);
|
||||
if (rc == -1) return -1;
|
||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
slurp_eq(const char *a, const char *b)
|
||||
{
|
||||
FILE *fa = fopen(a, "rb");
|
||||
FILE *fb = fopen(b, "rb");
|
||||
if (!fa || !fb) { if (fa) fclose(fa); if (fb) fclose(fb); return -1; }
|
||||
int rc = 0;
|
||||
for (;;) {
|
||||
int ca = fgetc(fa), cb = fgetc(fb);
|
||||
if (ca != cb) { rc = -1; break; }
|
||||
if (ca == EOF) break;
|
||||
}
|
||||
fclose(fa); fclose(fb);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#define K_RUN 0 /* build+run BOTH, exits==wants, + byte-id */
|
||||
#define K_BUILDERR 1 /* build FAILS with experr on BOTH drivers */
|
||||
#define K_RUN_NOID 2 /* build+run BOTH, exits==wants, byte-id
|
||||
* SKIPPED — cite the blocking task */
|
||||
#define K_CSERR_WWRUN 3 /* dual-cell bound row: cstage build must
|
||||
* FAIL with experr; wwstage build+run,
|
||||
* exit==wwwant — cite the blocking task */
|
||||
|
||||
struct row { const char *label; const char *src;
|
||||
int cswant; int wwwant; int kind; const char *experr; };
|
||||
|
||||
/* errlog_has — a builderr cell must fail WITH its diagnostic; any other
|
||||
* failure (parse error, crash, hang-kill) is a vacuous reject (940
|
||||
* precedent). */
|
||||
static int
|
||||
errlog_has(const char *path, const char *needle)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
char buf[8192];
|
||||
size_t got = fread(buf, 1, sizeof buf - 1, f);
|
||||
fclose(f);
|
||||
buf[got] = '\0';
|
||||
return strstr(buf, needle) != NULL;
|
||||
}
|
||||
|
||||
static const struct row rows[] = {
|
||||
/* ---- c1: helper + funnel internalization (the F2c-cs fuse) */
|
||||
{ "signed_ctl",
|
||||
"package main;\n"
|
||||
"type s0 = i8;\n"
|
||||
"type s1 = s0;\n"
|
||||
"type st = struct { f: s1, g: s1 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st;\n"
|
||||
" x.f = -5;\n"
|
||||
" x.g = 3;\n"
|
||||
" if (x.f >= 0) { return 1; };\n"
|
||||
" let w: i64 = x.f: i64;\n"
|
||||
" if (w != -5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* LIVE c1 graduation: tagged_arg_size single-peeled the 2-level
|
||||
* alias union param to 0 → wrong arg path (cs exit 1 SILENT, ww
|
||||
* correct). */
|
||||
{ "targ_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"fn h(v: u) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: u = 42i64;\n"
|
||||
" return h(x);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* LIVE c1 graduation: the >48B MEMORY-class twin
|
||||
* (tagged_memarg_size). LAST payload word checked. */
|
||||
{ "tmem_2lvl",
|
||||
"package main;\n"
|
||||
"type big = struct { a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, g: i64 };\n"
|
||||
"type m0 = (void | big);\n"
|
||||
"type m = m0;\n"
|
||||
"fn h(v: m) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let s: big => { if (s.g != 77) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: big;\n"
|
||||
" s.a = 11; s.b = 22; s.c = 33; s.d = 44; s.e = 55; s.f = 66; s.g = 77;\n"
|
||||
" let x: m = s;\n"
|
||||
" return h(x);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wpush_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"fn h(v: u) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" return h(42i64);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wstore_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wstore_1lvl",
|
||||
"package main;\n"
|
||||
"type u = (void | i64);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* C1-CORR-2 (ken c1-boundary addendum): the assign-route
|
||||
* divergence does NOT close in this train — the ident-lhs
|
||||
* N_ASSIGN tagged store gates in the cgexpr INLINE set (B6),
|
||||
* never reaching the :2456 funnel. Both stages runtime-correct;
|
||||
* byte-id rides B6. */
|
||||
{ "wstore_a_bound_b6",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = void;\n"
|
||||
" v = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN_NOID, NULL }, /* byte-id: B6 */
|
||||
/* C1-CORR-1: the residual divergence is exactly three paired
|
||||
* return-position tag syntheses — the cgreturn return-route
|
||||
* family (:12278/:12318/:12322). Joins c3's graduation set
|
||||
* (pins-follow-the-layer); flips to K_RUN there. */
|
||||
{ "succ_bound_c3",
|
||||
"package main;\n"
|
||||
"type e0 = !i64;\n"
|
||||
"type r0 = (i64 | e0);\n"
|
||||
"type r = r0;\n"
|
||||
"fn w(bad: bool) r = {\n"
|
||||
" if (bad) { return 7: e0; };\n"
|
||||
" return 42;\n"
|
||||
"};\n"
|
||||
"fn outer() r = {\n"
|
||||
" let v = w(false)?;\n"
|
||||
" return v + 1;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (outer()) {\n"
|
||||
" case let n: i64 => { if (n != 43) { return 1; }; };\n"
|
||||
" case e0 => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN_NOID, NULL }, /* byte-id: c3 */
|
||||
{ "null_2lvl",
|
||||
"package main;\n"
|
||||
"type np0 = (*i64 | void);\n"
|
||||
"type np = np0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let n: i64 = 31;\n"
|
||||
" let p: np = &n;\n"
|
||||
" match (p) {\n"
|
||||
" case let q: *i64 => { if (*q != 31) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "f32p_2lvl",
|
||||
"package main;\n"
|
||||
"type in0 = struct { a: f64 };\n"
|
||||
"type in1 = in0;\n"
|
||||
"type pt = struct { x: in1, y: f64 };\n"
|
||||
"fn g(p: pt) f64 = { return p.x.a + p.y; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let p: pt;\n"
|
||||
" p.x.a = 2.5;\n"
|
||||
" p.y = 1.5;\n"
|
||||
" if (g(p) != 4.0) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* fill loudness control: named-struct array elem louds on BOTH
|
||||
* stages with twin texts — the experr substring is shared. */
|
||||
{ "fill0_ctl",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64 };\n"
|
||||
"type S = struct { arr: [2]el0, n: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S { arr = [el0 { a = 5 }, el0 { a = 6 }], n = 3 };\n"
|
||||
" if (s.arr[0].a + s.arr[1].a + s.n != 14) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"has a str/slice/struct/tagged element" },
|
||||
/* DESIGNED IN-TRAIN ACCEPTANCE DIVERGENCE (B5 re-rule R4, task
|
||||
* #100): pre-c1 this was both-wrong-IDENTICAL-silent (gate-blind
|
||||
* #263 class — both stages accepted and ran exit 1 byte-id). The
|
||||
* cs-only :3195 chase flips cs to the fill0 fatal; ww's own
|
||||
* alias-blind twin gate (checkarrlitfits kin) stays silent-wrong
|
||||
* until #100 lands — then this row graduates to a both-loud
|
||||
* fill0-class pair. Both cells asserted. */
|
||||
{ "fill2_bound100",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64 };\n"
|
||||
"type el = el0;\n"
|
||||
"type S = struct { arr: [2]el, n: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S { arr = [el0 { a = 5 }, el0 { a = 6 }], n = 3 };\n"
|
||||
" if (s.arr[0].a + s.arr[1].a + s.n != 14) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 1, K_CSERR_WWRUN,
|
||||
"has a str/slice/struct/tagged element" }, /* ww: task #100 */
|
||||
/* node_tuplearg:249 pin (ken FLAG-2): the LITERAL spelling has
|
||||
* NO GREEN TARGET — cs checker-rejects even at 1 level (#86-kin)
|
||||
* while WW ACCEPTS AND RUNS WRONG (exit 1, task #99 metric-1
|
||||
* ww-side). Cells pinned as observed. */
|
||||
{ "tuparg_bound99",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9);\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 1, K_CSERR_WWRUN,
|
||||
"not assignable" }, /* ww: task #99 */
|
||||
{ "tuparg1_bound99", /* 1-LEVEL identical — not alias-depth */
|
||||
"package main;\n"
|
||||
"type tp = (i64, i64);\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9);\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 1, K_CSERR_WWRUN,
|
||||
"not assignable" }, /* ww: task #99 */
|
||||
/* C1-CORR-3 (corrects rob R3 + ken FLAG-2): the CAST spelling
|
||||
* dodges the cs checker, and the :249 chase gave it a LIVE cs
|
||||
* graduation — cs now classifies the alias-tuple arg and runs
|
||||
* CORRECT. ww still runs WRONG (#99). Two-key pin: cs-0 earned
|
||||
* + ww-1 pinned OBSERVED-WRONG; byte-id waived — when #99's ww
|
||||
* fix lands, the ww cell reds and forces the re-pin to full 0/0
|
||||
* byte-id (the designed graduation path). */
|
||||
{ "tuparg_cast_bound99",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9): tp;\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 1, K_RUN_NOID, NULL }, /* ww+byte-id: task #99 */
|
||||
/* #85 SITE-closure bound: type_unwrap's consumers (:14716/:14907
|
||||
* tuple-global layout walks) are checker-DEAD on cs for alias
|
||||
* tuples (#86 upstream) — the c1 chase graduates NOTHING live
|
||||
* here; ww runs the global correctly. */
|
||||
{ "tupglobal_bound86",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"let G: tp = (4, 9);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (G.0 + G.1 != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_CSERR_WWRUN,
|
||||
"not assignable" }, /* cs: task #86 */
|
||||
};
|
||||
|
||||
static int
|
||||
run_driver(const char *driver, const struct row *r, int i, int expect_err,
|
||||
int want)
|
||||
{
|
||||
char src[96], tmpdir[96], errf[96], cmd[1024];
|
||||
snprintf(src, sizeof src, "/tmp/ab5_%d_%d.ww", getpid(), i);
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/ab5_%d_d_%d", getpid(), i);
|
||||
snprintf(errf, sizeof errf, "/tmp/ab5_%d_e_%d", getpid(), i);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 20 %s build %s >/dev/null 2>%s",
|
||||
tmpdir, driver, src, errf);
|
||||
int brc = runwait(cmd);
|
||||
if (expect_err) {
|
||||
int ok = (brc != 0)
|
||||
&& (r->experr == NULL || errlog_has(errf, r->experr));
|
||||
if (!ok)
|
||||
fprintf(stderr, "row[%s]: %s expected loud builderr "
|
||||
"\"%s\" (brc=%d)\n", r->label, driver,
|
||||
r->experr ? r->experr : "", brc);
|
||||
unlink(src); unlink(errf); rmdir(tmpdir);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
if (brc != 0) {
|
||||
fprintf(stderr, "row[%s]: build via %s failed\n",
|
||||
r->label, driver);
|
||||
unlink(src); unlink(errf); rmdir(tmpdir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *base = strrchr(src, '/');
|
||||
base = base ? base + 1 : src;
|
||||
char outbin[256];
|
||||
snprintf(outbin, sizeof outbin, "%s/%s", tmpdir, base);
|
||||
char *dot = strrchr(outbin, '.');
|
||||
if (dot && strcmp(dot, ".ww") == 0) *dot = '\0';
|
||||
int got = runwait(outbin);
|
||||
|
||||
unlink(src); unlink(outbin); unlink(errf); rmdir(tmpdir);
|
||||
if (got != want) {
|
||||
fprintf(stderr, "row[%s]: %s exit %d, want %d\n",
|
||||
r->label, driver, got, want);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asm_byte_identical(const char *bin, const struct row *r, int i)
|
||||
{
|
||||
char src[96], cs[96], ws[96], cmd[1024];
|
||||
snprintf(src, sizeof src, "/tmp/ab5_asm_%d_%d.ww", getpid(), i);
|
||||
snprintf(cs, sizeof cs, "/tmp/ab5_asm_%d_%d_c.s", getpid(), i);
|
||||
snprintf(ws, sizeof ws, "/tmp/ab5_asm_%d_%d_w.s", getpid(), i);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null", bin, cs, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c errored\n", r->label);
|
||||
unlink(src);
|
||||
return -1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null",
|
||||
bin, ws, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww errored\n", r->label);
|
||||
unlink(src); unlink(cs);
|
||||
return -1;
|
||||
}
|
||||
int rc = slurp_eq(cs, ws);
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "row[%s]: cstage vs wwstage asm differs\n",
|
||||
r->label);
|
||||
unlink(src); unlink(cs); unlink(ws);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *bin = getenv("BIN");
|
||||
if (!bin) bin = "out/bin";
|
||||
char absbin[2080];
|
||||
if (bin[0] != '/') {
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
char cdrv[2120], wdrv[2120];
|
||||
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int total = 0, fail = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
int cs_err = rows[i].kind == K_BUILDERR
|
||||
|| rows[i].kind == K_CSERR_WWRUN;
|
||||
if (run_driver(cdrv, &rows[i], i, cs_err,
|
||||
rows[i].cswant) != 0) fail++;
|
||||
}
|
||||
if (access(wdrv, X_OK) == 0) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
int ww_err = rows[i].kind == K_BUILDERR;
|
||||
if (run_driver(wdrv, &rows[i], i, ww_err,
|
||||
rows[i].wwwant) != 0) fail++;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (rows[i].kind != K_RUN)
|
||||
continue;
|
||||
total++;
|
||||
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "alias_cgen_b5: %d/%d checks failed\n",
|
||||
fail, total);
|
||||
return 1;
|
||||
}
|
||||
printf("alias_cgen_b5: %d/%d ok\n", total, total);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user