diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-02-19 15:24:22 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-02-19 20:21:48 +0200 |
| commit | 89f6ff177178dba4e66680227a02de7b4068123c (patch) | |
| tree | 8363dfe4f78e21c681b3c59b504813bbf3734dd8 /src/codegen/llvm.zig | |
| parent | e02749224357a33cffcaf9970d14c199adc3d892 (diff) | |
| download | zig-89f6ff177178dba4e66680227a02de7b4068123c.tar.gz zig-89f6ff177178dba4e66680227a02de7b4068123c.zip | |
stage2: correct use of .unwrap_err_union_* in LLVM and C backend
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index ed57562e4c..8af74fce64 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3165,8 +3165,9 @@ pub const FuncGen = struct { const ty_op = self.air.instructions.items(.data)[inst].ty_op; const operand = try self.resolveInst(ty_op.operand); - const err_union_ty = self.air.typeOf(ty_op.operand); - const payload_ty = err_union_ty.errorUnionPayload(); + const result_ty = self.air.getRefType(ty_op.ty); + const payload_ty = if (operand_is_ptr) result_ty.childType() else result_ty; + if (!payload_ty.hasRuntimeBits()) return null; if (operand_is_ptr or isByRef(payload_ty)) { return self.builder.buildStructGEP(operand, 1, ""); @@ -3185,14 +3186,15 @@ pub const FuncGen = struct { const ty_op = self.air.instructions.items(.data)[inst].ty_op; const operand = try self.resolveInst(ty_op.operand); const operand_ty = self.air.typeOf(ty_op.operand); + const err_set_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty; - const payload_ty = operand_ty.errorUnionPayload(); + const payload_ty = err_set_ty.errorUnionPayload(); if (!payload_ty.hasRuntimeBits()) { if (!operand_is_ptr) return operand; return self.builder.buildLoad(operand, ""); } - if (operand_is_ptr or isByRef(payload_ty)) { + if (operand_is_ptr or isByRef(err_set_ty)) { const err_field_ptr = self.builder.buildStructGEP(operand, 0, ""); return self.builder.buildLoad(err_field_ptr, ""); } |
