fix(callgenmixin): 字面量 0 改 t.CSizeT(0)——修复 i32 实参与 i64 形参不一致
根因(反汇编实锤):空参数构造走 can==0 分支,字面量 0 是 i32,生成 IR call 实参 i32 与 declare i64 不一致 → llc 按 i32 生成 movl(4 字节写 can 槽)→ i64 形参高 4 字节残留垃圾 → callee 读 can=[垃圾][count]。StringIterTest can=0x2B2_... 崩溃根因。 修复:三处 _translate_struct_ctor(..., cargs, 0, trans) 字面量 0 → t.CSizeT(0)(i64),IR 实参与 declare 一致 → llc movq 写 8 字节。
This commit is contained in:
1 parent
8cc6996577
commit
a9d71714b3
1 file changed
+4
-4
@@ -313,7 +313,7 @@ class CallGenMixin(CallGenBase.CallGenBase):
|
||||
ctor_is_oop = gen_ctor_entry.IsOOP
|
||||
if ctor_is_oop != 0:
|
||||
return self.Gen.CallGenCtor._translate_struct_ctor(
|
||||
pool, builder, mod, struct_ty, func_name, cargs, 0, trans)
|
||||
pool, builder, mod, struct_ty, func_name, cargs, t.CSizeT(0), trans)
|
||||
# @t.NoVTable 类(无方法、类语义/指针对象):无参构造也应分配内存
|
||||
# 返回指针。否则按值结构体返回 ConstZero(struct_ty),LHS 联合注解
|
||||
# (如 Plain|CPtr)存 0 指针 → p.v 解引用 NULL 段错误
|
||||
@@ -323,7 +323,7 @@ class CallGenMixin(CallGenBase.CallGenBase):
|
||||
ctor_is_novt = gen_ctor_entry.IsNoVTable
|
||||
if ctor_is_novt != 0:
|
||||
return self.Gen.CallGenCtor._translate_struct_ctor(
|
||||
pool, builder, mod, struct_ty, func_name, cargs, 0, trans)
|
||||
pool, builder, mod, struct_ty, func_name, cargs, t.CSizeT(0), trans)
|
||||
# 普通结构体:检查是否有默认值(用 entry 直接访问)
|
||||
gen_has_defaults: int = 0
|
||||
if gen_ctor_entry is not None:
|
||||
@@ -338,7 +338,7 @@ class CallGenMixin(CallGenBase.CallGenBase):
|
||||
if gen_has_defaults == 1:
|
||||
# 有默认值:走构造函数路径应用默认值
|
||||
return self.Gen.CallGenCtor._translate_struct_ctor(
|
||||
pool, builder, mod, struct_ty, func_name, cargs, 0, trans)
|
||||
pool, builder, mod, struct_ty, func_name, cargs, t.CSizeT(0), trans)
|
||||
# 无默认值:返回 zeroinitializer
|
||||
ret: llvmlite.Value | t.CPtr = llvmlite.ConstZero(pool, struct_ty)
|
||||
return ret
|
||||
@@ -1254,7 +1254,7 @@ class CallGenMixin(CallGenBase.CallGenBase):
|
||||
# 检查被调用函数是否为变长函数(*args),若是则对变长参数进行 C ABI 提升
|
||||
# (cargs 为本函数参数 AST 链表,self_offset=0 普通函数调用)
|
||||
is_variadic_call: int = self.Gen.CallGenVa._check_and_promote_variadic_call(
|
||||
pool, builder, mod, call_name, head, can, cargs, 0, trans)
|
||||
pool, builder, mod, call_name, head, can, cargs, t.CSizeT(0), trans)
|
||||
# try-except:被调函数带 EH 输出参数时,追加输出实参 + 调用后检测异常
|
||||
return self.Gen.CallGenLeafKit._emit_eh_guarded_call(
|
||||
builder, pool, mod, trans, found_func, call_name, head, can,
|
||||
|
||||
Reference in new issue
Block a user