chore: 清理超长历史注释,并一并提交并行会话的代码改动

注释清理(65 文件 / 约 -2578 行 / 约 516 处):删除/压缩叙述式历史注释——多行根因叙事、工作代号段(D25/D30/N11/B5/S4/阶段E 等)、改前改后与先例叙述、逐条推导块,压成一行讲清作用信息;契约类注释(用途、参数与返回、关键约束与不变量、IR 结构说明)与被注释掉的代码一律保留

存疑 标记 6 处一字未动:StubMergerStore.vp、VpiReader.vp、VLogger.vp、AssignGenMixin.vp、CallGenLib.vp、CallGenLeafKit.vp

本次一并带入并行会话的代码改动(同批文件,按文件粒度无法拆分):fileio.File -> rowptr[fileio.File] 等

已知副作用/残留:① CallGenDispatch.vp 有 2 行非注释行的行尾被 LF->CRLF 规范化(纯字节变化,无文本改动);② core/Gen 区约 24 处压缩因并行会话整文件覆写被写回原样,尚未生效(StmtGenCifMixin/ClassGenVTable/FuncGenDef/ClassGenEnum/StructGenMixin/TypeSpec 等)

清单与复跑判据见 Debugger/comment_cleanup_summary.md(该目录不受版本控制)
This commit is contained in:
TermiNexus committed 2026-09-16 11:27:05 +08:00
1 parent b28f20cce7
commit 7cba4cbc95
65 files changed
+1233 -3292

No files matched your search

+4 -34
View File
@@ -388,14 +388,7 @@ class CallGenCBuiltin(CallGenBase.CallGenBase):
return nl_addr
return_var: llvmlite.Value | t.CPtr = self.Gen.VarGen.lookup_var(trans.SymTab, nm.id)
if return_var is None and mod is not None:
# 模块全局变量:c.Addr(模块全局) → 返回全局变量指针。
# 此前局部符号表查找失败即返回 None → 跌落跨模块函数调用路径
# 生成 call @Addr(裸名,无 obj 定义)→ ld.lld undefined symbol:
# Addr(VKernel main.vp L87 c.Addr(ncpu_cr) 及 4d/8d/a1/c3/d3
# 大量模块全局取地址根因)。必须经 make_global_ref 转成带引号的
# Ptr(Ty) 引用——直接返回 GlobalVariable 节点时其 Ty 是 pointee、
# Name 无 @ 引号,参与 ptrtoint 会渲染成 "ptrtoint void to i64"
# (llc: void type only allowed for function results)。
# 模块全局变量 c.Addr(模块全局) → 返回全局变量指针:必须经 make_global_ref 转成带引号的 Ptr(Ty) 引用(直接返回 GlobalVariable 节点时其 Ty 是 pointee、Name 无 @ 引号,参与 ptrtoint 会渲染成 "ptrtoint void to i64")
gv_ref_nm: llvmlite.GlobalVariable | t.CPtr = self.Gen.ExprGenAttr.find_global_in_module(mod, nm.id)
if gv_ref_nm is not None and gv_ref_nm.Name is not None and gv_ref_nm.Ty is not None:
return_var = self.Gen.ExprGenAttr.make_global_ref(pool, gv_ref_nm.Name, gv_ref_nm.Ty)
@@ -472,13 +465,7 @@ class CallGenCBuiltin(CallGenBase.CallGenBase):
at_addr: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(arg0)
if at_addr is None or at_addr.attr is None or at_addr.value is None:
return None
# 跨模块函数地址:c.Addr(serial.puts) → 函数符号本身(@sha1.puts)。
# 此前 Attribute 分支只支持 self/cls 字段 GEP;serial.puts 的 value 是
# 已导入模块名(非局部变量)→ 下方 self_alloca 查找失败 return None →
# 回退 ExprGenAttr 当全局变量处理(创建 @sha1.puts external global i8*
# + load)→ 与 vpi 注入的 puts 函数 declare 同名冲突 → llc
# "redefinition of function '@a6890f1aeecb0aaf.puts'"
# (elf.vp L485 c.Addr(serial.puts) 根因)。
# 跨模块函数地址 c.Addr(serial.puts) → 函数符号本身(@sha1.puts):不可回退 ExprGenAttr 当全局变量处理,否则与 vpi 注入的 puts 函数 declare 同名冲突(llc "redefinition of function")
if at_addr.value.kind() == ast.ASTKind.Name and trans is not None \
and trans._imported_modules is not None:
mod_nm2: ast.Name | t.CPtr = (ast.Name | t.CPtr)(at_addr.value)
@@ -490,17 +477,7 @@ class CallGenCBuiltin(CallGenBase.CallGenBase):
if f_ref2 is not None:
fname2: str = llvmlite.function_get_name(f_ref2)
if fname2 is not None:
# 构造带 @ 名的 SSAValue(Ptr(FuncTy)):直接返回
# Function 节点会被 IRBuilder 格式化成 RetTy(void)
# → "bitcast void to i8*"(elf.vp L2874 根因)。
# Function 无 Ty 字段(成员仅 Next/Name/RetTy/
# Params/Blocks/IsDeclared/IsVarArg/Attrs),
# 用 RetTy+Params 重建函数类型。Params 是
# GSList(含 Head 字段),必须经
# function_get_param_head 取链表头——直接
# 把 Params 当 Param 遍历会读 GSList.Head/
# Next 当 Name/Ty → 垃圾参数类型
# "i32 (i1425633744, i8*)"(elf.vp L2874 根因)。
# 构造带 @ 名的 SSAValue(Ptr(FuncTy)):直接返回 Function 节点会被 IRBuilder 格式化成 RetTy(void)→ "bitcast void to i8*"。Function 无 Ty 字段,用 RetTy+Params 重建函数类型;Params 是 GSList,必须经 function_get_param_head 取链表头(当 Param 直接遍历会读出垃圾参数类型)
p_head2: llvmlite.Param | t.CPtr = llvmlite.function_get_param_head(f_ref2)
p_cnt2: sizet = 0
p_cur2: llvmlite.Param | t.CPtr = p_head2
@@ -522,14 +499,7 @@ class CallGenCBuiltin(CallGenBase.CallGenBase):
return llvmlite.SSAValue(
pool, llvmlite.Ptr(pool, fn_ty2), faddr_buf2)
else:
# 模块限定全局:c.Addr(gdt.gp) → 全局符号本身(@gp)。
# 跨模块全局(含 CExport 裸名 @gp)已注入为 external
# global。经 make_global_ref 转成带引号的 Ptr(Ty) 引用
# (直接返回 GlobalVariable 节点会渲染 "ptrtoint void")。
# 此前未处理 → return None → 跌落跨模块函数调用路径
# 生成 call @Addr(裸名,无 obj 定义)→ ld.lld
# undefined symbol: Addr(apic.vp L193 c.Addr(gdt.gp)
# / L199 c.Addr(idt.idt) 根因)。
# 模块限定全局 c.Addr(gdt.gp) → 全局符号本身(@gp):跨模块全局(含 CExport 裸名)已注入为 external global,经 make_global_ref 转成带引号的 Ptr(Ty) 引用(直接返回 GlobalVariable 节点会渲染 "ptrtoint void")
g_ref2: llvmlite.GlobalVariable | t.CPtr = self.Gen.ExprGenAttr.find_global_in_module(
mod, at_addr.attr)
if g_ref2 is not None and g_ref2.Name is not None and g_ref2.Ty is not None: