mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-29 10:27:48 +00:00
Fix race condition with code_gen_module
This commit is contained in:
@@ -250,7 +250,7 @@ struct DeclInfo {
|
||||
i64 variadic_reuse_max_align;
|
||||
|
||||
// NOTE(bill): this is to prevent a race condition since these procedure literals can be created anywhere at any time
|
||||
struct lbModule *code_gen_module;
|
||||
std::atomic<struct lbModule *> code_gen_module;
|
||||
};
|
||||
|
||||
// ProcInfo stores the information needed for checking a procedure
|
||||
|
||||
@@ -498,10 +498,11 @@ gb_internal lbModule *lb_module_of_expr(lbGenerator *gen, Ast *expr) {
|
||||
gb_internal lbModule *lb_module_of_entity_internal(lbGenerator *gen, Entity *e, lbModule *curr_module) {
|
||||
lbModule **found = nullptr;
|
||||
|
||||
if (e->kind == Entity_Procedure &&
|
||||
e->decl_info &&
|
||||
e->decl_info->code_gen_module) {
|
||||
return e->decl_info->code_gen_module;
|
||||
if (e->kind == Entity_Procedure && e->decl_info) {
|
||||
lbModule *mod = e->decl_info->code_gen_module.load(std::memory_order_relaxed);
|
||||
if (mod) {
|
||||
return mod;
|
||||
}
|
||||
}
|
||||
if (e->file) {
|
||||
found = map_get(&gen->modules, cast(void *)e->file);
|
||||
|
||||
Reference in New Issue
Block a user