| ... | @@ -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-used | 885 | 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 developer | 888 | 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 | } |
| 4026 | | 4027 | |
| 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) |