fix(mlirlite): MLIR 间接调用点也过 alias 解析,callee 不再悬空

no-op bitcast(含函数指针 bitcast)被 alias 机制省略后,参数用法会改写成别名目标,
但 llvm.call 的 callee 位置原样写出 → 悬空 %N,mlir-opt 报 use of undeclared SSA value /
definition of SSA value has type 'i8' but previously used here with type '!llvm.ptr'。

- _MlirCall:callee 走 _MlirResolve,并用解析后的名字判断直接/间接调用
  (别名解析可能把 callee 指到 @符号,那就成了直接调用,不能再写 !llvm.ptr)
This commit is contained in:
TermiNexus committed 2026-10-12 13:18:51 +08:00
1 parent 4914311014
commit bca23ffa06
1 file changed
+8 -2
+8 -2
View File
@@ -2611,7 +2611,12 @@ def _MlirCall(p: str, resname: str, out: str, outsz: sizet):
else:
_MlirEmitRes(out, outsz, resname)
_append_cstr(out, outsz, "llvm.call ")
_append_cstr(out, outsz, calb)
# callee 也必须过 alias 解析:no-op bitcast(含函数指针 bitcast)被省略后,间接调用点
# 必须改写成别名目标,否则 %N 悬空 → mlir-opt 报 use of undeclared SSA value
# / definition has type 'i8' but previously used here with type '!llvm.ptr'。
calb_r: str = _MlirResolve(calb)
if calb_r is None: calb_r = calb
_append_cstr(out, outsz, calb_r)
_append_cstr(out, outsz, "(")
_append_cstr(out, outsz, args)
_append_cstr(out, outsz, ")")
@@ -2629,8 +2634,9 @@ def _MlirCall(p: str, resname: str, out: str, outsz: sizet):
# (omitting vararg's `)` made mlir-opt 22.1.8 report "expected ')'" verbatim)
_append_cstr(out, outsz, ")>)")
_append_cstr(out, outsz, " : ")
if calb[0] != '@':
if calb_r[0] != '@':
# Indirect call: the callee is a !llvm.ptr operand
# (用解析后的名字判断:别名解析可能把 callee 指到一个 @符号,那就成了直接调用)
_append_cstr(out, outsz, "!llvm.ptr, ")
_append_cstr(out, outsz, "(")
_append_cstr(out, outsz, argts)