w6c: sret-wire the chained-leaf call store (o.a.b = wide())

The chained value-struct walker's N_CALL arm handled only <=24B
register returns; an sret-class rhs fell to the scalar tail and
stored ONE word (the sret dest pointer) into the leaf -- silent
truncation in BOTH stages, byteid-blind. Point the callee's hidden
RDI at the BP-relative leaf slot (the single-dot #234 arm verbatim);
a ptr-root/global chain joins the #234-tail loud-stop family.
This commit is contained in:
2026-08-08 23:51:17 +09:00
parent 62b9d20383
commit 94928470bc
4 changed files with 81 additions and 4 deletions

View File

@@ -12052,6 +12052,31 @@ fn cgassign(c: *cgen, n: *syntax.node) void = {
};
return;
};
// #234: over-cap sret STORE into a chained
// value-struct leaf — `o.a.b = wide();`
// (sretretsize > 0: a >24B struct OR an
// over-cap tuple). Point the callee's hidden
// RDI dest at the leaf slot so it writes the
// WHOLE value there; pre-#234 this fell to
// the scalar tail and stored ONE word (the
// sret dest pointer). c.sretdestoff is
// BP-relative ONLY, so a ptr-root/global
// chain needs the runtime RDI-pointer dest
// variant deferred to #234-tail and HARD-
// STOPS loud (rule 7).
if (n.rhs != nil
&& n.rhs.kind == syntax.nkind.N_CALL
&& sretretsizetn(c, leaftype) > 0) {
if (viacx) {
let m234: str = "#234-tail: over-cap tuple sret store to chained ptr/global dest unsupported\n";
os.write(2, m234.ptr, m234.len: u64);
os.exit(1);
};
c.sretdestoff = rootoff + totaloff;
cgexpr(c, n.rhs);
c.sretdestoff = 0;
return;
};
// TY_STRUCT terminal: three rhs shapes:
// - N_IDENT: word-copy from the rhs local slot
// (cgexpr is skipped — no whole-struct register