diff options
| author | Luuk de Gram <luuk@degram.dev> | 2023-05-07 18:48:25 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2023-05-19 20:18:59 +0200 |
| commit | f2860bb4f40565e43f51757e6cb604bb2df16ae0 (patch) | |
| tree | 0ce47a009490895869afd5522ea7243a55fb6150 /src/arch | |
| parent | 67d27dbe631d1292be363f4121217d66e2d7fd0f (diff) | |
| download | zig-f2860bb4f40565e43f51757e6cb604bb2df16ae0.tar.gz zig-f2860bb4f40565e43f51757e6cb604bb2df16ae0.zip | |
wasm: more liveness fixes
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index c2d2ffd8e4..29253797d2 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -880,10 +880,11 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void { // TODO: Upon branch consolidation free any locals if needed. const value = func.currentBranch().values.getPtr(ref) orelse return; if (value.* != .local) return; - log.debug("Decreasing reference for ref: %{?d}\n", .{Air.refToIndex(ref)}); - if (value.local.value < func.arg_index) { + const reserved_indexes = func.args.len + @boolToInt(func.return_value != .none); + if (value.local.value < reserved_indexes) { return; // function arguments can never be re-used } + log.debug("Decreasing reference for ref: %{?d}, using local '{d}'\n", .{ Air.refToIndex(ref), value.local.value }); value.local.references -= 1; // if this panics, a call to `reuseOperand` was forgotten by the developer if (value.local.references == 0) { value.free(func); @@ -4024,7 +4025,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { return func.fail("todo Wasm intcast for bitsize > 128", .{}); } - const op_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?; + const op_bits = toWasmBits(@intCast(u16, operand_ty.bitSize(func.target))).?; const wanted_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?; const result = if (op_bits == wanted_bits) func.reuseOperand(ty_op.operand, operand) |
