chore(diag): [GVAR-DIAG] 模块级全局类型决策(hasnew/hasvtable/isoop) - 定位 CAM 被包成 Ptr

This commit is contained in:
TermiNexus committed 2026-10-15 23:06:20 +08:00
1 parent 15a210bede
commit 9d0a43d5e6
1 file changed
+8
+8
View File
@@ -548,6 +548,14 @@ novirtual class TranslatorGenMixin:
# resolved struct value in Ptr; pure t.CStruct keeps a value instance.
if resolved.kind() == mlirlite.LLVMType.Struct:
gv_entry: GenTypes.StructEntry* = self.Gen.StructGen.find_struct_by_type(resolved)
# [TEMP-DIAG] 模块级 struct 全局的类型决策(定位完删除):
# hasnew/hasvtable/isoop 任一为真 ⇒ 全局被包成 Ptr(指针槽),
# 与"局部变量=值本体"不一致 ⇒ `CAM = V3(...)` 被当成把栈地址交给全局。
gv_hn: int = -1; gv_hv: int = -1; gv_oo: int = -1
if gv_entry is not None:
gv_hn = gv_entry.HasNew; gv_hv = gv_entry.HasVTable; gv_oo = gv_entry.IsOOP
stdio.printf("[GVAR-DIAG] name=%s hasnew=%d hasvtable=%d isoop=%d\n",
var_name, gv_hn, gv_hv, gv_oo)
if gv_entry is not None and (gv_entry.HasNew != 0 or gv_entry.HasVTable != 0 or gv_entry.IsOOP != 0):
# Object-class global (object-as-pointer): remember the Struct value type
# so a BSS storage global can hold the instance; otherwise @g is NULL.