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 {...@@ -880,10 +880,11 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void {
880 // TODO: Upon branch consolidation free any locals if needed.880 // TODO: Upon branch consolidation free any locals if needed.
881 const value = func.currentBranch().values.getPtr(ref) orelse return;881 const value = func.currentBranch().values.getPtr(ref) orelse return;
882 if (value.* != .local) return;882 if (value.* != .local) return;
883 log.debug("Decreasing reference for ref: %{?d}\n", .{Air.refToIndex(ref)});883 const reserved_indexes = func.args.len + @boolToInt(func.return_value != .none);
884 if (value.local.value < func.arg_index) {884 if (value.local.value < reserved_indexes) {
885 return; // function arguments can never be re-used885 return; // function arguments can never be re-used
886 }886 }
887 log.debug("Decreasing reference for ref: %{?d}, using local '{d}'\n", .{ Air.refToIndex(ref), value.local.value });
887 value.local.references -= 1; // if this panics, a call to `reuseOperand` was forgotten by the developer888 value.local.references -= 1; // if this panics, a call to `reuseOperand` was forgotten by the developer
888 if (value.local.references == 0) {889 if (value.local.references == 0) {
889 value.free(func);890 value.free(func);
...@@ -4024,7 +4025,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4024,7 +4025,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4024 return func.fail("todo Wasm intcast for bitsize > 128", .{});4025 return func.fail("todo Wasm intcast for bitsize > 128", .{});
4025 }4026 }
40264027
4027 const op_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?;4028 const op_bits = toWasmBits(@intCast(u16, operand_ty.bitSize(func.target))).?;
4028 const wanted_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?;4029 const wanted_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?;
4029 const result = if (op_bits == wanted_bits)4030 const result = if (op_bits == wanted_bits)
4030 func.reuseOperand(ty_op.operand, operand)4031 func.reuseOperand(ty_op.operand, operand)