fix(tpv): f-string 隐式 snprintf 声明形参 buf/fmt 用 i8* 而非裸 i8

f-string 降级为 snprintf 时按"隐式提供"原则在使用点补 declare,但三段固定
参数里的 buf/fmt 误写成数组元素类型 i8(应为指针 i8*),与调用侧传入的
buf_ptr/fmt_ptr(i8*)不匹配 → MLIR 'llvm.call' operand type mismatch
'!llvm.ptr' != 'i8'(ZlibDbg 编译失败根因)。改为 Ptr(i8)。
This commit is contained in:
TermiNexus committed 2026-10-04 20:51:38 +08:00
1 parent 68cd5f2f90
commit 4236127956
1 file changed
+6 -2
+6 -2
View File
@@ -193,9 +193,13 @@ novirtual class ExprGenFstr(ExprGenBase.ExprGenBase):
snprintf_decl: mlirlite.Function* = mlirlite.create_declare(pool, mod, "snprintf", i32_ty)
if snprintf_decl is not None:
snprintf_decl.IsVarArg = 1
mlirlite.add_param(pool, snprintf_decl, i8_ty, "buf")
# buf/fmt 是指针参数(i8*),**不是**元素类型 i8(buf_ty 的 elem):
# 调用侧传 buf_ptr/fmt_ptr(i8*),declare 若写成裸 i8 → MLIR
# 'llvm.call' operand type mismatch '!llvm.ptr' != 'i8'(ZlibDbg 根因)。
i8_ptr_ty: mlirlite.LLVMType* = mlirlite.Ptr(pool, i8_ty)
mlirlite.add_param(pool, snprintf_decl, i8_ptr_ty, "buf")
mlirlite.add_param(pool, snprintf_decl, mlirlite.Int64(pool), "size")
mlirlite.add_param(pool, snprintf_decl, i8_ty, "fmt")
mlirlite.add_param(pool, snprintf_decl, i8_ptr_ty, "fmt")
# snprintf(buf, FSTR_BUF_SIZE, fmt, args...)
size_val: mlirlite.Value* = mlirlite.const_int64(pool, FSTR_BUF_SIZE)
buf_ptr.Next = size_val