aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_general.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm_backend_general.cpp')
-rw-r--r--src/llvm_backend_general.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index 57eb869fa..cae08ec2f 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -2226,6 +2226,18 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
if (is_type_union_maybe_pointer(type)) {
LLVMTypeRef variant = lb_type(m, type->Union.variants[0]);
array_add(&fields, variant);
+ } else if (type->Union.variants.count == 1) {
+ LLVMTypeRef block_type = lb_type(m, type->Union.variants[0]);
+
+ LLVMTypeRef tag_type = lb_type(m, union_tag_type(type));
+ array_add(&fields, block_type);
+ array_add(&fields, tag_type);
+ i64 used_size = lb_sizeof(block_type) + lb_sizeof(tag_type);
+ i64 padding = size - used_size;
+ if (padding > 0) {
+ LLVMTypeRef padding_type = lb_type_padding_filler(m, padding, align);
+ array_add(&fields, padding_type);
+ }
} else {
LLVMTypeRef block_type = nullptr;
@@ -3131,7 +3143,6 @@ gb_internal lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &pr
lbValue *found = map_get(&target_module->values, e);
rw_mutex_shared_unlock(&target_module->values_mutex);
if (found == nullptr) {
- // THIS IS THE RACE CONDITION
lbProcedure *missing_proc_in_target_module = lb_create_procedure(target_module, e, false);
array_add(&target_module->missing_procedures_to_check, missing_proc_in_target_module);
}