Add warning in code generation stage which might cause a possible code gen issue, when non-constant initialization is large

This commit is contained in:
gingerBill
2026-01-22 13:54:53 +00:00
parent 78ed2560d3
commit 5072d5c776
2 changed files with 13 additions and 0 deletions

View File

@@ -2045,6 +2045,11 @@ gb_internal bool lb_init_global_var(lbModule *m, lbProcedure *p, Entity *e, Ast
lb_emit_store(p, data, lb_emit_conv(p, gp, t_rawptr));
lb_emit_store(p, ti, lb_typeid(p->module, var_type));
} else {
i64 sz = type_size_of(e->type);
if (sz >= 4 * 1024) {
warning(init_expr, "[Possible Code Generation Issue] Non-constant initialization is large (%lld bytes), and might cause problems with LLVM", cast(long long)sz);
}
LLVMTypeRef vt = llvm_addr_type(p->module, var.var);
lbValue src0 = lb_emit_conv(p, var.init, t);
LLVMValueRef src = OdinLLVMBuildTransmute(p, src0.value, vt);