diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-15 20:03:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-15 20:03:58 -0400 |
| commit | 1149e8bb088f48e29f3abc06196b1134f5e1c42f (patch) | |
| tree | b3637be2086b25649d71e2d24d334aa634e87e03 /src/codegen/llvm.zig | |
| parent | 7d0b6956c0935807f0e5862c45da857e8e065c6b (diff) | |
| parent | 480e7eec65c02952b71ecc2f4ff2adccb6092a5f (diff) | |
| download | zig-1149e8bb088f48e29f3abc06196b1134f5e1c42f.tar.gz zig-1149e8bb088f48e29f3abc06196b1134f5e1c42f.zip | |
Merge pull request #11185 from topolarity/bugfix-11159
stage2: resolve panic on array-like tuple initialization
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 692edd48c1..343e503aea 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -5422,21 +5422,22 @@ pub const FuncGen = struct { const bin_op = self.air.instructions.items(.data)[inst].bin_op; const dest_ptr = try self.resolveInst(bin_op.lhs); const ptr_ty = self.air.typeOf(bin_op.lhs); + const operand_ty = ptr_ty.childType(); + if (!operand_ty.isFnOrHasRuntimeBitsIgnoreComptime()) return null; // TODO Sema should emit a different instruction when the store should // possibly do the safety 0xaa bytes for undefined. const val_is_undef = if (self.air.value(bin_op.rhs)) |val| val.isUndefDeep() else false; if (val_is_undef) { - const elem_ty = ptr_ty.childType(); const target = self.dg.module.getTarget(); - const elem_size = elem_ty.abiSize(target); + const operand_size = operand_ty.abiSize(target); const u8_llvm_ty = self.context.intType(8); const ptr_u8_llvm_ty = u8_llvm_ty.pointerType(0); const dest_ptr_u8 = self.builder.buildBitCast(dest_ptr, ptr_u8_llvm_ty, ""); const fill_char = u8_llvm_ty.constInt(0xaa, .False); const dest_ptr_align = ptr_ty.ptrAlignment(target); const usize_llvm_ty = try self.dg.llvmType(Type.usize); - const len = usize_llvm_ty.constInt(elem_size, .False); + const len = usize_llvm_ty.constInt(operand_size, .False); _ = self.builder.buildMemSet(dest_ptr_u8, fill_char, len, dest_ptr_align, ptr_ty.isVolatilePtr()); if (self.dg.module.comp.bin_file.options.valgrind) { // TODO generate valgrind client request to mark byte range as undefined |
