w6c: return of a module-global struct ident copies the global's bytes

cstage zeroed the return scratch; mirror the landed wwstage emission
(copy from the g(SB) base). Flips the F8-era residual row to
cs==ww==correct. Task #42.
This commit is contained in:
2026-06-12 22:34:31 +09:00
parent 5ff5f4b4fe
commit 960b1e796d
2 changed files with 25 additions and 25 deletions

View File

@@ -13675,12 +13675,21 @@ cgstmt(Cg *c, Node *n, Local **locals, int *frame)
scr + idx * esz));
idx++;
}
} else if (n->lhs->kind == N_IDENT) {
} else if (n->lhs->kind == N_IDENT
&& localfind(*locals, n->lhs->str) != 0) {
/* N_IDENT: word-copy rhs slot into
* scratch. Whole 8B words via MOVQ;
* trailing partial word via MOVL/MOVB
* so we read no further than the
* source slot's declared size. */
* source slot's declared size.
*
* #42 (#263): only a LOCAL ident has a
* BP slot. A module-global struct ident
* (localfind==0) falls to the addr-copy
* else below — aggarg_srcaddr lands
* g(SB) in SI. Pre-fix this read frame
* garbage off 0(BP). ww half landed
* F8-c6. */
int rhsoff = localfind(*locals,
n->lhs->str);
int k = 0;