mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-30 00:41:35 +00:00
Fix #6786
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user