aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-02-02 10:58:25 +0000
committergingerBill <gingerBill@users.noreply.github.com>2026-02-02 10:58:25 +0000
commitacabae8644dc5fb9cfb1c7dbb2f45625529ab760 (patch)
tree1d7e460a887901d4237363423b340569bc365c1c /src
parent8a92ba74fc90b70f56af5e0dcfd37c16aab94595 (diff)
Make `Entity.parent_proc_decl` atomic
Diffstat (limited to 'src')
-rw-r--r--src/entity.cpp4
-rw-r--r--src/llvm_backend_proc.cpp6
-rw-r--r--src/name_canonicalization.cpp4
3 files changed, 8 insertions, 6 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index 97c908fea..070b05462 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -170,7 +170,7 @@ struct Entity {
Type * type;
std::atomic<Ast *> identifier; // Can be nullptr
DeclInfo * decl_info;
- DeclInfo * parent_proc_decl; // nullptr if in file/global scope
+ std::atomic<DeclInfo *> parent_proc_decl; // nullptr if in file/global scope
AstFile * file;
AstPackage *pkg;
@@ -370,7 +370,7 @@ gb_internal Entity *alloc_entity_using_variable(Entity *parent, Token token, Typ
token.pos = parent->token.pos;
Entity *entity = alloc_entity(Entity_Variable, parent->scope, token, type);
entity->using_parent = parent;
- entity->parent_proc_decl = parent->parent_proc_decl;
+ entity->parent_proc_decl.store(parent->parent_proc_decl, std::memory_order_relaxed);
entity->using_expr = using_expr;
entity->flags |= EntityFlag_Using;
entity->flags |= EntityFlag_Used;
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index dc502717e..44a463e31 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -2215,8 +2215,10 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
Entity *e = entity_of_node(ident);
GB_ASSERT(e != nullptr);
- if (e->parent_proc_decl != nullptr && e->parent_proc_decl->entity != nullptr) {
- procedure = e->parent_proc_decl->entity.load()->token.string;
+ DeclInfo *parent_proc_decl = e->parent_proc_decl.load(std::memory_order_relaxed);
+ if (parent_proc_decl != nullptr &&
+ parent_proc_decl->entity != nullptr) {
+ procedure = parent_proc_decl->entity.load()->token.string;
} else {
procedure = str_lit("");
}
diff --git a/src/name_canonicalization.cpp b/src/name_canonicalization.cpp
index f1dccb182..d3faefed7 100644
--- a/src/name_canonicalization.cpp
+++ b/src/name_canonicalization.cpp
@@ -559,8 +559,8 @@ gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e) {
// no prefix
return;
}
- if (e->parent_proc_decl) {
- Entity *p = e->parent_proc_decl->entity;
+ if (e->parent_proc_decl.load(std::memory_order_relaxed)) {
+ Entity *p = e->parent_proc_decl.load(std::memory_order_relaxed)->entity;
write_canonical_parent_prefix(w, p);
type_writer_append(w, p->token.string.text, p->token.string.len);
if (is_type_polymorphic(p->type)) {