diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-25 16:10:09 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-27 01:31:18 +0300 |
| commit | 595ccecd88d82874e7f677ee1809c04fc29424ff (patch) | |
| tree | 3acfaec42fe6313fb36a7bfc4512ec8a07c05d62 /src/codegen | |
| parent | 5b79f42dc5220850b67ac461a326d5a6253da215 (diff) | |
| download | zig-595ccecd88d82874e7f677ee1809c04fc29424ff.tar.gz zig-595ccecd88d82874e7f677ee1809c04fc29424ff.zip | |
llvm: do not return undefined pointers from array_to_slice
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 18b89eef78..2eb95dc5e3 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -5434,10 +5434,11 @@ pub const FuncGen = struct { const llvm_usize = try self.dg.lowerType(Type.usize); const len = llvm_usize.constInt(array_ty.arrayLen(), .False); const slice_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst)); + const operand = try self.resolveInst(ty_op.operand); if (!array_ty.hasRuntimeBitsIgnoreComptime()) { - return self.builder.buildInsertValue(slice_llvm_ty.getUndef(), len, 1, ""); + const partial = self.builder.buildInsertValue(slice_llvm_ty.getUndef(), operand, 0, ""); + return self.builder.buildInsertValue(partial, len, 1, ""); } - const operand = try self.resolveInst(ty_op.operand); const indices: [2]*llvm.Value = .{ llvm_usize.constNull(), llvm_usize.constNull(), }; |
