This commit is contained in:
gingerBill
2026-06-29 10:49:29 +01:00
parent a4dcf8f5d6
commit e227c736e6
2 changed files with 15 additions and 7 deletions

View File

@@ -2498,7 +2498,7 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
return LLVMStructTypeInContext(ctx, fields, gb_count_of(fields), false);
}
auto fields = array_make<LLVMTypeRef>(temporary_allocator(), 0, 3);
auto fields = array_make<LLVMTypeRef>(temporary_allocator(), 0, 4);
if (is_type_union_maybe_pointer(type)) {
LLVMTypeRef variant = lb_type(m, type->Union.variants[0]);
array_add(&fields, variant);
@@ -2519,6 +2519,12 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
LLVMTypeRef tag_type = lb_type(m, union_tag_type(type));
array_add(&fields, block_type);
#if LLVM_VERSION_MAJOR > 14
{ // NOTE(bill): always add a zero-byte pad to make inline constant unions work
LLVMTypeRef padding_type = lb_type_padding_filler(m, 0, 1);
array_add(&fields, padding_type);
}
#endif
array_add(&fields, tag_type);
i64 used_size = lb_sizeof(block_type) + lb_sizeof(tag_type);
i64 padding = size - used_size;
@@ -2528,7 +2534,7 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
}
}
return LLVMStructTypeInContext(ctx, fields.data, cast(unsigned)fields.count, false);
return LLVMStructTypeInContext(ctx, fields.data, cast(unsigned)fields.count, /*packed*/true);
}
break;