| ... | ... | @@ -881,6 +881,9 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void { |
| 881 | 881 | const value = func.currentBranch().values.getPtr(ref) orelse return; |
| 882 | 882 | if (value.* != .local) return; |
| 883 | 883 | log.debug("Decreasing reference for ref: %{?d}\n", .{Air.refToIndex(ref)}); |
| 884 | if (value.local.value < func.arg_index) { |
| 885 | return; // function arguments can never be re-used |
| 886 | } |
| 884 | 887 | value.local.references -= 1; // if this panics, a call to `reuseOperand` was forgotten by the developer |
| 885 | 888 | if (value.local.references == 0) { |
| 886 | 889 | value.free(func); |
| ... | ... | @@ -4021,7 +4024,13 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4021 | 4024 | return func.fail("todo Wasm intcast for bitsize > 128", .{}); |
| 4022 | 4025 | } |
| 4023 | 4026 | |
| 4024 | | const result = try (try func.intcast(operand, operand_ty, ty)).toLocal(func, ty); |
| 4027 | const op_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?; |
| 4028 | const wanted_bits = toWasmBits(@intCast(u16, ty.bitSize(func.target))).?; |
| 4029 | const result = if (op_bits == wanted_bits) |
| 4030 | func.reuseOperand(ty_op.operand, operand) |
| 4031 | else |
| 4032 | try (try func.intcast(operand, operand_ty, ty)).toLocal(func, ty); |
| 4033 | |
| 4025 | 4034 | func.finishAir(inst, result, &.{}); |
| 4026 | 4035 | } |
| 4027 | 4036 | |