Improve global array index to be on a per module basis

This commit is contained in:
gingerBill
2025-02-25 15:06:13 +00:00
parent 92f6d2745b
commit 400348c925
4 changed files with 20 additions and 22 deletions
+2 -1
View File
@@ -3308,13 +3308,14 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
{
isize max_len = 7+8+1;
name = gb_alloc_array(permanent_allocator(), char, max_len);
u32 id = m->gen->global_array_index.fetch_add(1);
u32 id = m->global_array_index.fetch_add(1);
isize len = gb_snprintf(name, max_len, "csbs$%x", id);
len -= 1;
}
LLVMTypeRef type = LLVMTypeOf(array);
LLVMValueRef global_data = LLVMAddGlobal(m->mod, type, name);
LLVMSetInitializer(global_data, array);
LLVMSetUnnamedAddress(global_data, LLVMGlobalUnnamedAddr);
LLVMSetLinkage(global_data, LLVMInternalLinkage);