wcc: converge let-IDENT memcpy, IDENT-assign recv, nested struct call-recv onto structabisize
Three more wwstage cgen sites still used unrounded structnaturalsize where cstage rounds via lu->size — pre-existing gate-blind cs!=ww latents the #169b reviewer surfaced: cgenstmt N_LET struct-IDENT memcpy (let p2: T = p1; twin cgen.c:7869), cgenexpr N_ASSIGN N_IDENT-lhs register RECV (s = mk(); twin cgen.c:4700-4737), and cgenutil's nested struct N_CALL recv inside cgstructlitfill (twin cgen.c:2121). Converge all three onto structabisize, completing the same-class closure started by #169 and continued by #169b. Also corrected the inline comment at cgenutil.ww:3273-3286 that wrongly claimed fl->type->size was natural (check.c:760 sets ABI). sretretsize at cgenutil.ww:1301 is gate-equivalent natural and is left alone. Probe 698 +3 rows (one per converged site) with cs==ww .s byte-cmp and a pre-fix-rebuild discriminator. 990-997 byte-id hold.
This commit is contained in:
@@ -17337,21 +17337,22 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node,
|
||||
if (primsize(fi.tnode.str) == 0) {
|
||||
let csi: *structinfo = structlookup(c, fi.tnode.str);
|
||||
if (csi != nil) {
|
||||
// Use the inner struct's
|
||||
// NATURAL size (no 8B slot
|
||||
// rounding) so MOVL/MOVW/
|
||||
// MOVB tail dispatch matches
|
||||
// cstage's fl->type->size
|
||||
// (which is natural per
|
||||
// check.c). fi.fsz here is
|
||||
// Inner struct's ABI size
|
||||
// (maxalign-rounded) — cstage
|
||||
// reads fl->type->size at the
|
||||
// nested-call branch
|
||||
// (cgen.c:2121); check.c:760
|
||||
// sets that to the
|
||||
// maxalign-rounded ABI extent
|
||||
// (NOT natural). fi.fsz is
|
||||
// wwstage's slot-padded
|
||||
// totsize — using it would
|
||||
// emit 2× MOVQ where cstage
|
||||
// emits MOVQ+MOVL for a
|
||||
// 12B inner, etc. (task #15
|
||||
// territory; sidestepped
|
||||
// locally.)
|
||||
let cfsz: i32 = structnaturalsize(csi);
|
||||
// totsize (round-to-8); the
|
||||
// pre-#169 structnaturalsize
|
||||
// shorts struct{i64,i32}
|
||||
// (natural 12, ABI 16) to
|
||||
// MOVQ+MOVL where cstage
|
||||
// writes MOVQ+MOVQ.
|
||||
let cfsz: i32 = structabisize(csi);
|
||||
let crem: i32 = cfsz - (cfsz / 8) * 8;
|
||||
if (cfsz <= 24) {
|
||||
if (crem == 0 || crem == 1
|
||||
@@ -24267,9 +24268,14 @@ fn cgassign(c: *cgen, n: *node) void = {
|
||||
if (lcsname.len > 0) {
|
||||
let lcsi: *structinfo = structlookup(c, lcsname);
|
||||
if (lcsi != nil) {
|
||||
// si.totsize is slot-padded (rounded to 8);
|
||||
// receive ABI needs the TYPE's natural size.
|
||||
let lcnsz: i32 = structnaturalsize(lcsi);
|
||||
// register RECV reads AX/DX/CX at 8-byte
|
||||
// granularity — size via structabisize (cstage
|
||||
// N_ASSIGN-IDENT branch sets sz = lu->size,
|
||||
// cgen.c:4704; check.c:760 SSoT). The pre-
|
||||
// #169 structnaturalsize shorts struct{i64,i32}
|
||||
// (natural 12, ABI 16) to MOVQ+MOVL where
|
||||
// cstage writes MOVQ+MOVQ.
|
||||
let lcnsz: i32 = structabisize(lcsi);
|
||||
if (n.op == tkind.TK_ASSIGN) {
|
||||
if (n.rhs != nil
|
||||
&& n.rhs.kind == nkind.N_STRUCTLIT) {
|
||||
@@ -25876,8 +25882,8 @@ fn cglet(c: *cgen, n: *node) void = {
|
||||
// Struct ident copy: `let p2: T = p1;` where T is a struct
|
||||
// >8B and rhs is a local ident. Per-qword MOVQ from src
|
||||
// slot to dst slot, with a sized tail (MOVL/MOVB) for
|
||||
// natural sizes that aren't 8-aligned (e.g. `struct
|
||||
// { i32, i32, i32 }` is 12B). Pre-fix this path fell
|
||||
// ABI sizes that aren't 8-aligned (e.g. `struct
|
||||
// { i32, i32, i32 }`, maxalign 4 → ABI 12B). Pre-fix this path fell
|
||||
// through to `cgexpr + MOVQ AX, off(BP)` which stored
|
||||
// only the first qword (and a stale BX for sz==16 lets
|
||||
// via the str-init tail) — silent partial copy. Mirrors
|
||||
@@ -25891,7 +25897,13 @@ fn cglet(c: *cgen, n: *node) void = {
|
||||
if (sname.len > 0) {
|
||||
let lsi: *structinfo = structlookup(c, sname);
|
||||
if (lsi != nil) {
|
||||
let lsz: i32 = structnaturalsize(lsi);
|
||||
// memcpy run sizes on the maxalign-rounded ABI
|
||||
// size — cstage N_LET sets sz = lu->size
|
||||
// (cgen.c:7533, struct-IDENT branch :7869),
|
||||
// check.c:760 SSoT. structnaturalsize would
|
||||
// short struct{i64,i32} (natural 12, ABI 16)
|
||||
// to MOVQ+MOVL where cstage writes MOVQ+MOVQ.
|
||||
let lsz: i32 = structabisize(lsi);
|
||||
if (lsz > 8) {
|
||||
let lc: *local = localfindnode(c, rhs.str);
|
||||
if (lc != nil) {
|
||||
|
||||
Reference in New Issue
Block a user