diff options
| author | gingerBill <bill@gingerbill.org> | 2023-04-18 17:20:50 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-04-18 17:20:50 +0100 |
| commit | 843eaf8893e3a7df9645c0bcba86c71a01a14765 (patch) | |
| tree | 25ff685d654e7063d30022b2a979d69a39c3de6e /src/llvm_backend_general.cpp | |
| parent | 30fa8f8ac2cd19442e027042a3b0031f294b9cd2 (diff) | |
Fix race condition with -use-separate-modules due to type determination
Diffstat (limited to 'src/llvm_backend_general.cpp')
| -rw-r--r-- | src/llvm_backend_general.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index aa887418f..7d2f574fe 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -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; |