From 4236127956fe21234887137f7e421e4f567b1124 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 4 Oct 2026 20:51:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(tpv):=20f-string=20=E9=9A=90=E5=BC=8F=20snp?= =?UTF-8?q?rintf=20=E5=A3=B0=E6=98=8E=E5=BD=A2=E5=8F=82=20buf/fmt=20?= =?UTF-8?q?=E7=94=A8=20i8*=20=E8=80=8C=E9=9D=9E=E8=A3=B8=20i8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)。 --- App/lib/core/Gen/Expr/ExprGenFstr.vp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/App/lib/core/Gen/Expr/ExprGenFstr.vp b/App/lib/core/Gen/Expr/ExprGenFstr.vp index 1df465a..7748aba 100644 --- a/App/lib/core/Gen/Expr/ExprGenFstr.vp +++ b/App/lib/core/Gen/Expr/ExprGenFstr.vp @@ -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