authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-25 16:10:09+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-27 01:31:18+03:00
log595ccecd88d82874e7f677ee1809c04fc29424ff
tree3acfaec42fe6313fb36a7bfc4512ec8a07c05d62
parent5b79f42dc5220850b67ac461a326d5a6253da215

llvm: do not return undefined pointers from array_to_slice


1 files changed, 3 insertions(+), 2 deletions(-)

src/codegen/llvm.zig+3-2
...@@ -5434,10 +5434,11 @@ pub const FuncGen = struct {...@@ -5434,10 +5434,11 @@ pub const FuncGen = struct {
5434 const llvm_usize = try self.dg.lowerType(Type.usize);5434 const llvm_usize = try self.dg.lowerType(Type.usize);
5435 const len = llvm_usize.constInt(array_ty.arrayLen(), .False);5435 const len = llvm_usize.constInt(array_ty.arrayLen(), .False);
5436 const slice_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst));5436 const slice_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst));
5437 const operand = try self.resolveInst(ty_op.operand);
5437 if (!array_ty.hasRuntimeBitsIgnoreComptime()) {5438 if (!array_ty.hasRuntimeBitsIgnoreComptime()) {
5438 return self.builder.buildInsertValue(slice_llvm_ty.getUndef(), len, 1, "");5439 const partial = self.builder.buildInsertValue(slice_llvm_ty.getUndef(), operand, 0, "");
5440 return self.builder.buildInsertValue(partial, len, 1, "");
5439 }5441 }
5440 const operand = try self.resolveInst(ty_op.operand);
5441 const indices: [2]*llvm.Value = .{5442 const indices: [2]*llvm.Value = .{
5442 llvm_usize.constNull(), llvm_usize.constNull(),5443 llvm_usize.constNull(), llvm_usize.constNull(),
5443 };5444 };