w6c: widen of a module-global struct ident copies the full payload

cstage zero-filled the payload; mirror the landed wwstage emission.
Flips the residual row to cs==ww==correct. Task #43.
This commit is contained in:
2026-06-12 22:37:56 +09:00
parent 960b1e796d
commit ca4ff4b882
2 changed files with 29 additions and 24 deletions

View File

@@ -2925,9 +2925,21 @@ cg_widen_tagged_store(Cg *c, Local **locals_p, Type *dst, Node *src,
if (src->kind == N_IDENT) {
int soff = localfind(*locals_p, src->str);
int ssz = (int)su->size;
int srcreg = D_BP, srcbase = soff;
if (soff == 0) {
/* #43 (#263): a module-global struct ident has
* no BP slot — land g(SB) in SI (aggarg_srcaddr)
* and copy the struct words into slot+8. Pre-fix
* the BP copy read frame garbage off 0(BP). ww
* half landed F8-c7. */
if (aggarg_srcaddr(c, src, D_SI, *locals_p)) {
srcreg = D_SI;
srcbase = 0;
}
}
int k = 0;
while (k + 8 <= ssz) {
ins2(c, A_MOVQ, amem(D_BP, soff + k),
ins2(c, A_MOVQ, amem(srcreg, srcbase + k),
areg(D_AX));
ins2(c, A_MOVQ, areg(D_AX),
amem(D_BP, write_off + 8 + k));
@@ -2942,7 +2954,7 @@ cg_widen_tagged_store(Cg *c, Local **locals_p, Type *dst, Node *src,
int lop = (tail == 4) ? A_MOVL :
(tail == 1 ? A_MOVB : A_MOVQ);
ins2(c, lop,
amem(D_BP, soff + k), areg(D_AX));
amem(srcreg, srcbase + k), areg(D_AX));
ins2(c, lop, areg(D_AX),
amem(D_BP, write_off + 8 + k));
}