aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorXavier Bouchoux <xavierb@gmail.com>2023-10-03 05:34:19 +0000
committerXavier Bouchoux <xavierb@gmail.com>2023-10-03 05:34:19 +0000
commit405705cb76914072b9a91ac29f7cf0bf67b255f4 (patch)
tree2f2928e3a6c42626cf1464a2f52dba546ea6e50d /src/codegen
parent62d178e91af57c19d0ac000fe6930039a23e53a3 (diff)
downloadzig-405705cb76914072b9a91ac29f7cf0bf67b255f4.tar.gz
zig-405705cb76914072b9a91ac29f7cf0bf67b255f4.zip
codegen: fix byte-aligned field offsets in unaligned nested packed structs
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 753e02a857..236584f44f 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -10140,6 +10140,7 @@ pub const FuncGen = struct {
const result_ty = self.typeOfIndex(inst);
const result_ty_info = result_ty.ptrInfo(mod);
const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
+ const struct_type = mod.typeToStruct(struct_ty).?;
if (result_ty_info.packed_offset.host_size != 0) {
// From LLVM's perspective, a pointer to a packed struct and a pointer
@@ -10151,7 +10152,7 @@ pub const FuncGen = struct {
// We have a pointer to a packed struct field that happens to be byte-aligned.
// Offset our operand pointer by the correct number of bytes.
- const byte_offset = struct_ty.packedStructFieldByteOffset(field_index, mod) + @divExact(struct_ptr_ty_info.packed_offset.bit_offset, 8);
+ const byte_offset = @divExact(mod.structPackedFieldBitOffset(struct_type, field_index) + struct_ptr_ty_info.packed_offset.bit_offset, 8);
if (byte_offset == 0) return struct_ptr;
const usize_ty = try o.lowerType(Type.usize);
const llvm_index = try o.builder.intValue(usize_ty, byte_offset);