Fix race condition with -use-separate-modules due to type determination

This commit is contained in:
gingerBill
2023-04-18 17:20:50 +01:00
parent 30fa8f8ac2
commit 843eaf8893
3 changed files with 18 additions and 3 deletions
+6
View File
@@ -1498,6 +1498,9 @@ gb_internal LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *t
type = base_type(original_type);
GB_ASSERT(type->kind == Type_Proc);
mutex_lock(&m->func_raw_types_mutex);
defer (mutex_unlock(&m->func_raw_types_mutex));
LLVMTypeRef *found = map_get(&m->func_raw_types, type);
if (found) {
return *found;
@@ -2157,6 +2160,9 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
gb_internal LLVMTypeRef lb_type(lbModule *m, Type *type) {
type = default_type(type);
mutex_lock(&m->types_mutex);
defer (mutex_unlock(&m->types_mutex));
LLVMTypeRef *found = map_get(&m->types, type);
if (found) {
return *found;