authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-27 23:33:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-27 23:35:56-07:00
log11911f55a73a49e2fda85bddd38d1993b93547c9
tree0ee9eb36a44a230fb356aec6f0e056b3e74c186a
parent9d098657a069b36e3eed9bc63c3421c031be7348

stage1: fix incorrect struct padding

Before this change, struct {f80, f80} targeting i386-windows-msvc lowers to ```llvm %"std.testing.struct:78:61.6" = type { x86_fp80, [6 x i8], x86_fp80, [6 x i8] } ``` which has an incorrect ABI size of 40. After this change, the struct lowers to ```llvm %"std.testing.struct:78:61.6" = type { x86_fp80, [4 x i8], x86_fp80, [4 x i8] } ``` which has the correct ABI size of 32, and properly aligns the second field to 16 bytes. The other place that calculates field padding (lowering of constant values in codegen.cpp) already correctly calls LLVMABISizeOfType rather than LLVMStoreSizeOfType. This fixes the compiler-rt tests for i386-windows in this branch.

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

src/stage1/analyze.cpp+1-1
...@@ -8928,7 +8928,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -8928,7 +8928,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
89288928
8929 assert(next_offset >= llvm_next_offset);8929 assert(next_offset >= llvm_next_offset);
8930 if (next_offset > llvm_next_offset) {8930 if (next_offset > llvm_next_offset) {
8931 size_t pad_bytes = next_offset - (field->offset + LLVMStoreSizeOfType(g->target_data_ref, llvm_type));8931 size_t pad_bytes = next_offset - (field->offset + LLVMABISizeOfType(g->target_data_ref, llvm_type));
8932 if (pad_bytes != 0) {8932 if (pad_bytes != 0) {
8933 LLVMTypeRef pad_llvm_type = LLVMArrayType(LLVMInt8Type(), pad_bytes);8933 LLVMTypeRef pad_llvm_type = LLVMArrayType(LLVMInt8Type(), pad_bytes);
8934 element_types[gen_field_index] = pad_llvm_type;8934 element_types[gen_field_index] = pad_llvm_type;