[Mlir-commits] [mlir] [MLIR][LLVMIR] Import calls with mismatching signature as indirect call (PR #135895)

Christian Ulmann llvmlistbot at llvm.org
Sun May 4 22:52:09 PDT 2025


================
@@ -1966,12 +1990,26 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
                                  unwindArgs)))
       return failure();
 
-    FailureOr<LLVMFunctionType> funcTy = convertFunctionType(invokeInst);
+    bool isIncompatibleInvoke;
+    FailureOr<LLVMFunctionType> funcTy =
+        convertFunctionType(invokeInst, isIncompatibleInvoke);
     if (failed(funcTy))
       return failure();
 
-    FlatSymbolRefAttr calleeName = convertCalleeName(invokeInst);
-
+    FlatSymbolRefAttr calleeName = nullptr;
+    if (isIncompatibleInvoke) {
+      // Use an indirect invoke (in order to represent valid and verifiable LLVM
+      // IR). Build the indirect invoke by passing an empty `callee` operand and
+      // insert into `operands` to include the indirect invoke target.
+      FlatSymbolRefAttr calleeSym = convertCalleeName(invokeInst);
+      Value indirectInvokeVal = builder.create<LLVM::AddressOfOp>(
+          translateLoc(invokeInst->getDebugLoc()),
----------------
Dinistro wrote:

As above

https://github.com/llvm/llvm-project/pull/135895


More information about the Mlir-commits mailing list