aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-02 23:05:27 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-04 15:57:40 -0700
commit3a9375cae9a3385278e43a2785f4ccfe0dc47c2e (patch)
tree2f6795a701780942c6cd48eb5f76180dfeb84f56 /src/arch/wasm/CodeGen.zig
parent954019983d17fad9dac1c80e2de92cb7ebe7cd08 (diff)
downloadzig-3a9375cae9a3385278e43a2785f4ccfe0dc47c2e.tar.gz
zig-3a9375cae9a3385278e43a2785f4ccfe0dc47c2e.zip
wasm codegen: fix some missing Liveness reaps
I did not do a full audit, but I did notice a few issues which are resolved in this commit. Probably it would be worth adding debug infrastructure to assert that the number of reaps equals the number of calls to resolveInst() per air lowering function.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index 1d24076154..d4e3559006 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -2001,7 +2001,7 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
try func.restoreStackPointer();
try func.addTag(.@"return");
- return func.finishAir(inst, .none, &.{});
+ return func.finishAir(inst, .none, &.{un_op});
}
fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) InnerError!void {
@@ -3161,7 +3161,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
break :result func.reuseOperand(ty_op.operand, operand);
} else WValue{ .none = {} };
- func.finishAir(inst, result, &.{});
+ func.finishAir(inst, result, &.{ty_op.operand});
}
fn bitcast(func: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) InnerError!WValue {
@@ -4115,7 +4115,7 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const len = try func.resolveInst(bin_op.rhs);
try func.memset(ptr, len, value);
- func.finishAir(inst, .none, &.{pl_op.operand});
+ func.finishAir(inst, .none, &.{ pl_op.operand, bin_op.lhs, bin_op.rhs });
}
/// Sets a region of memory at `ptr` to the value of `value`
@@ -4424,6 +4424,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
else => unreachable,
}
};
+ // TODO: this is incorrect Liveness handling code
func.finishAir(inst, result, &.{});
}
@@ -4747,7 +4748,7 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const len = try func.resolveInst(bin_op.rhs);
try func.memcpy(dst, src, len);
- func.finishAir(inst, .none, &.{pl_op.operand});
+ func.finishAir(inst, .none, &.{ pl_op.operand, bin_op.lhs, bin_op.rhs });
}
fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
@@ -5158,7 +5159,8 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: enum { max, min }) InnerE
fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;
- if (func.liveness.isUnused(inst)) return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
+ if (func.liveness.isUnused(inst))
+ return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs, pl_op.operand });
const ty = func.air.typeOfIndex(inst);
if (ty.zigTypeTag() == .Vector) {
@@ -5186,7 +5188,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
break :result try (try func.binOp(mul_result, addend, ty, .add)).toLocal(func, ty);
};
- func.finishAir(inst, result, &.{ bin_op.lhs, bin_op.rhs });
+ func.finishAir(inst, result, &.{ bin_op.lhs, bin_op.rhs, pl_op.operand });
}
fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {