From 1c3cdf349339daef2804815066e3c78675d59cef Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 13 Oct 2026 17:48:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(stub):=20=E6=B6=88=E8=B4=B9=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=A1=A5=E9=BD=90=E6=8C=89=E5=80=BC=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E8=81=9A=E5=90=88=E7=9A=84=E5=85=B7=E5=90=8D=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BD=93=E5=AE=8C=E6=95=B4=E4=BD=93=EF=BC=88=5Finject=5Fmethod?= =?UTF-8?q?=5Fdeclare=20=E8=A1=A5=20=5Fensure=5Ffull=5Fvalue=5Ftypes?= =?UTF-8?q?=E3=80=81=5Finject=5Fclass=5Fstruct=5Fdeclare=20=E8=A1=A5?= =?UTF-8?q?=E7=99=BB=E5=AE=8C=E6=95=B4=E5=AE=9A=E4=B9=89=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=20MLIR=20opaque=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/Stub/StubGen/VpiReader.vp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/App/lib/Stub/StubGen/VpiReader.vp b/App/lib/Stub/StubGen/VpiReader.vp index 1bfa96a..175a76a 100644 --- a/App/lib/Stub/StubGen/VpiReader.vp +++ b/App/lib/Stub/StubGen/VpiReader.vp @@ -2628,6 +2628,12 @@ def _inject_class_struct_declare(pool: memhub.MemBuddy*, mod: mlirlite.LLVMModul if existing_c is not None and existing_c.Ty is not None: if existing_c.IsForwardDecl != 0: fill_fwd_c = 1 else: + # entry 已在全局 StructTable(可能由别的模块先注入/注册),但**本模块**的 NamedTypeHead + # 不保证有它的完整定义:只有被按值使用(值返回类型 / 值字段 / 数组元素)时打印才回查登记 + # 表,而指针引用只会登记 opaque 前向声明 → 打印签名/类型时报 "still opaque"。故这里补齐 + # 本模块的完整定义(幂等:add_named_type 同名去重,完整定义替换 opaque)。 + mlirlite.module_add_named_type(mod, pool, existing_c.Ty) + if existing_c.IsPacked != 0: mlirlite.module_set_named_type_packed(mod, pool, existing_c.Ty, 1) GenApi.add_visible_struct(pool, real_name) return 1 # Skip REnum classes (class X(t.REnum)): their layout is computed from variants by @@ -3112,6 +3118,11 @@ def _inject_method_declare(pool: memhub.MemBuddy*, mod: mlirlite.LLVMModule*, m_ if ret_ty is None and string.strcmp(m_fd.name, "__init__") == 0: ret_ty = mlirlite.Void(pool) if ret_ty is None: ret_ty = i32_ty + # 跨模块方法**按值返回类**时,引用模块必须登记该具名结构体的完整定义:否则打印方法签名回查登记表, + # 命中的只是指针引用登记的 opaque 前向声明 → MLIR 报 "still opaque at print time"。与 + # _inject_function_declare 同口径(那里对值返回类型调 _ensure_full_value_types)。 + _ensure_full_value_types(mod, pool, ret_ty) + # create the declare func: mlirlite.Function* = mlirlite.create_declare(pool, mod, mangled_name, ret_ty) if func is None: return