wwstage: zero-init 8B composite locals in bare-let to match cstage (#213)
wwstage's cglet no-rhs path zero-inited only 8B primitives (MOVQ) and >8B composites (XORQ run), so an 8B *composite* local (single-field struct/tagged, e.g. struct{src:*vtable}) declared bare (let b: box;) was left uninitialized -- reading an unassigned field returned stack garbage (a silent read-before-init), and it diverged from cstage which zero-inits any 8B local (cs!=ww byte-id, surfaced by #5's bufio box{src:io.stream}). Add the missing arm: a non-array composite of size 8 emits MOVQ $0, matching cstage's no-rhs sz==8 zeroing. cstage unchanged (already correct -- align wwstage UP). Scope is 8B-only: cstage does not zero-init sub-8 composites either (sub-8 falls through to nothing on both stages, already cs==ww), so zeroing sub-8 on wwstage would create a new divergence; the sub-8 read-before-init garbage is a separate shared-both-stages latent (#20). Adds test/wcc/790 (8B byte-id row + read-before-init correctness lock reading 0 on both stages). rule-10 align-up; closes the #213 8B-composite slice; unblocks post-eFinal #5.
This commit is contained in:
@@ -27166,7 +27166,20 @@ fn cglet(c: *cgen, n: *node) void = {
|
||||
emitline("(BP)\n");
|
||||
zi += 1;
|
||||
};
|
||||
}; }; };
|
||||
} else { if (zsz == 8) {
|
||||
// #213: an 8B composite (single-field struct / tagged) is
|
||||
// neither an 8B primitive nor zsz>8, so it fell through
|
||||
// un-zeroed while cstage emits MOVQ $0 (cgen.c N_LET
|
||||
// `else if (sz == 8)`); a read-before-init then saw stack
|
||||
// garbage (cs!=ww byte-id + a latent garbage-read). Match
|
||||
// cstage. Sub-8 (4B/1B) composites stay un-zeroed — cstage
|
||||
// doesn't zero them either, so zeroing here would re-
|
||||
// diverge; that sub-8 read-before-init garbage is a SHARED
|
||||
// latent, out of this slice's scope.
|
||||
emitline("\tMOVQ\t$0, ");
|
||||
emitoff(off: i64);
|
||||
emitline("(BP)\n");
|
||||
}; }; }; };
|
||||
};
|
||||
c.lastwasreturn = 0;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user