diff --git a/mlirlite/__function.vp b/mlirlite/__function.vp index 654d088..4ba6cd2 100644 --- a/mlirlite/__function.vp +++ b/mlirlite/__function.vp @@ -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)