authorgravatar for william@sengir.comWilliam Sengir <william@sengir.com> 2022-04-23 02:54:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-16 13:55:26-07:00
loga5ea22d0693cf767fa47c9947399651ed3c35aaf
tree8e5297b765d01b9b2dbfb1b31196555065775e10
parentbb3532e775bb17fff1630103d4d29a650b7ad5c3

LLVM: correctly pad result tuple of `airOverflow`


1 files changed, 11 insertions(+), 1 deletions(-)

src/codegen/llvm.zig+11-1
......@@ -5605,14 +5605,24 @@ pub const FuncGen = struct {
56055605
56065606 const lhs_ty = self.air.typeOf(extra.lhs);
56075607 const scalar_ty = lhs_ty.scalarType();
5608 const dest_ty = self.air.typeOfIndex(inst);
56085609
56095610 const intrinsic_name = if (scalar_ty.isSignedInt()) signed_intrinsic else unsigned_intrinsic;
56105611
56115612 const llvm_lhs_ty = try self.dg.llvmType(lhs_ty);
5613 const llvm_dest_ty = try self.dg.llvmType(dest_ty);
5614
5615 const tg = self.dg.module.getTarget();
56125616
56135617 const llvm_fn = self.getIntrinsic(intrinsic_name, &.{llvm_lhs_ty});
56145618 const result_struct = self.builder.buildCall(llvm_fn, &[_]*const llvm.Value{ lhs, rhs }, 2, .Fast, .Auto, "");
5615 return result_struct;
5619
5620 const result = self.builder.buildExtractValue(result_struct, 0, "");
5621 const overflow_bit = self.builder.buildExtractValue(result_struct, 1, "");
5622
5623 var ty_buf: Type.Payload.Pointer = undefined;
5624 const partial = self.builder.buildInsertValue(llvm_dest_ty.getUndef(), result, llvmFieldIndex(dest_ty, 0, tg, &ty_buf).?, "");
5625 return self.builder.buildInsertValue(partial, overflow_bit, llvmFieldIndex(dest_ty, 1, tg, &ty_buf).?, "");
56165626 }
56175627
56185628 fn buildElementwiseCall(