authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-07 18:48:25+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-19 20:18:59+02:00
logf2860bb4f40565e43f51757e6cb604bb2df16ae0
tree0ce47a009490895869afd5522ea7243a55fb6150
parent67d27dbe631d1292be363f4121217d66e2d7fd0f
signaturelock-open Commit is signed but in an unrecognized format.

wasm: more liveness fixes


1 files changed, 4 insertions(+), 3 deletions(-)

src/arch/wasm/CodeGen.zig+4-3
......@@ -880,10 +880,11 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void {
880880 // TODO: Upon branch consolidation free any locals if needed.
881881 const value = func.currentBranch().values.getPtr(ref) orelse return;
882882 if (value.* != .local) return;
883 log.debug("Decreasing reference for ref: %{?d}\n", .{Air.refToIndex(ref)});
884 if (value.local.value < func.arg_index) {
883 const reserved_indexes = func.args.len + @boolToInt(func.return_value != .none);
884 if (value.local.value < reserved_indexes) {
885885 return; // function arguments can never be re-used
886886 }
887 log.debug("Decreasing reference for ref: %{?d}, using local '{d}'\n", .{ Air.refToIndex(ref), value.local.value });
887888 value.local.references -= 1; // if this panics, a call to `reuseOperand` was forgotten by the developer
888889 if (value.local.references == 0) {
889890 value.free(func);
......@@ -4024,7 +4025,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
40244025 return func.fail("todo Wasm intcast for bitsize > 128", .{});
40254026 }
40264027
4027 const op_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?;
4028 const op_bits = toWasmBits(@intCast(u16, operand_ty.bitSize(func.target))).?;
40284029 const wanted_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?;
40294030 const result = if (op_bits == wanted_bits)
40304031 func.reuseOperand(ty_op.operand, operand)