authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-30 21:55:44+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-31 18:04:33+02:00
logebfd3450d9a3338726e1ed8b08a5751b06604cd5
treea74bf6ee7003cb7dbba333866619829c85c58659
parent7e10cf4fbe2a8a379564941be9953ce157d483cc
signaturelock-open Commit is signed but in an unrecognized format.

codegen: Write padding bytes for unions

Previously we did not write any missing padding bytes after the smallest field (either tag or payload, depending on alignment). This resulted in writing too few bytes and not matching the full abisize of the union.

2 files changed, 6 insertions(+), 2 deletions(-)

src/arch/wasm/CodeGen.zig+2-2
......@@ -1726,8 +1726,8 @@ fn isByRef(ty: Type, target: std.Target) bool {
17261726
17271727 .Array,
17281728 .Frame,
1729 .Union,
1730 => {
1729 => return ty.hasRuntimeBitsIgnoreComptime(),
1730 .Union => {
17311731 if (ty.castTag(.@"union")) |union_ty| {
17321732 if (union_ty.data.layout == .Packed) {
17331733 return ty.abiSize(target) > 8;
src/codegen.zig+4
......@@ -611,6 +611,10 @@ pub fn generateSymbol(
611611 }
612612 }
613613
614 if (layout.padding > 0) {
615 try code.writer().writeByteNTimes(0, layout.padding);
616 }
617
614618 return Result.ok;
615619 },
616620 .Optional => {