From caa0de545e2f45a96ac3136178f478dab1c89ebd Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Mon, 19 Jul 2021 21:50:15 +0200 Subject: [PATCH] Resolve regressions - Get correct types in wasm backend. - `arg` is already a `Ref`, therefore simply use `@intToEnum`. - Fix regression in `zirBoolBr, where the order of insertion was incorrect. --- src/Sema.zig | 10 +++++----- src/codegen/wasm.zig | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Sema.zig b/src/Sema.zig index d796ae2a5a..b3feeb8b1c 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -5295,11 +5295,6 @@ fn zirBoolBr( then_block.instructions.items.len + else_block.instructions.items.len + @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len); - sema.air_instructions.items(.data)[block_inst].ty_pl.payload = sema.addExtraAssumeCapacity( - Air.Block{ .body_len = @intCast(u32, child_block.instructions.items.len) }, - ); - sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); - const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ .then_body_len = @intCast(u32, then_block.instructions.items.len), .else_body_len = @intCast(u32, else_block.instructions.items.len), @@ -5312,6 +5307,11 @@ fn zirBoolBr( .payload = cond_br_payload, } } }); + sema.air_instructions.items(.data)[block_inst].ty_pl.payload = sema.addExtraAssumeCapacity( + Air.Block{ .body_len = @intCast(u32, child_block.instructions.items.len) }, + ); + sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); + try parent_block.instructions.append(gpa, block_inst); return Air.indexToRef(block_inst); } diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig index b6edfb7b20..e72140d826 100644 --- a/src/codegen/wasm.zig +++ b/src/codegen/wasm.zig @@ -871,7 +871,7 @@ pub const Context = struct { }; for (args) |arg| { - const arg_val = self.resolveInst(Air.indexToRef(arg)); + const arg_val = self.resolveInst(@intToEnum(Air.Inst.Ref, arg)); try self.emitWValue(arg_val); } @@ -959,7 +959,7 @@ pub const Context = struct { try self.emitWValue(lhs); try self.emitWValue(rhs); - const bin_ty = self.air.getRefType(bin_op.lhs); + const bin_ty = self.air.typeOf(bin_op.lhs); const opcode: wasm.Opcode = buildOpcode(.{ .op = op, .valtype1 = try self.typeToValtype(bin_ty), @@ -1179,7 +1179,7 @@ pub const Context = struct { const data: Air.Inst.Data = self.air.instructions.items(.data)[inst]; const lhs = self.resolveInst(data.bin_op.lhs); const rhs = self.resolveInst(data.bin_op.rhs); - const lhs_ty = self.air.getRefType(data.bin_op.lhs); + const lhs_ty = self.air.typeOf(data.bin_op.lhs); try self.emitWValue(lhs); try self.emitWValue(rhs); @@ -1211,7 +1211,7 @@ pub const Context = struct { const br = self.air.instructions.items(.data)[inst].br; // if operand has codegen bits we should break with a value - if (self.air.getRefType(br.operand).hasCodeGenBits()) { + if (self.air.typeOf(br.operand).hasCodeGenBits()) { try self.emitWValue(self.resolveInst(br.operand)); } @@ -1277,7 +1277,7 @@ pub const Context = struct { const else_body = self.air.extra[extra.end + cases.len ..][0..extra.data.else_body_len]; const target = self.resolveInst(pl_op.operand); - const target_ty = self.air.getRefType(pl_op.operand); + const target_ty = self.air.typeOf(pl_op.operand); const valtype = try self.typeToValtype(target_ty); // result type is always 'noreturn' const blocktype = wasm.block_empty;