[Mlir-commits] [mlir] [mlir][LLVMIR] Add IFuncOp to LLVM dialect (PR #147697)

Tobias Gysi llvmlistbot at llvm.org
Fri Jul 11 12:13:02 PDT 2025


================
@@ -2682,6 +2694,59 @@ unsigned AliasOp::getAddrSpace() {
   return ptrTy.getAddressSpace();
 }
 
+//===----------------------------------------------------------------------===//
+// IFuncOp
+//===----------------------------------------------------------------------===//
+
+void IFuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
+                    Type iFuncType, StringRef resolverName, Type resolverType,
+                    Linkage linkage, LLVM::Visibility visibility) {
+  return build(builder, result, name, iFuncType, resolverName, resolverType,
+               linkage, /*dso_local=*/false, /*address_space=*/0,
+               UnnamedAddr::None, visibility);
+}
+
+LogicalResult IFuncOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
+  Operation *symbol =
+      symbolTable.lookupSymbolIn(parentLLVMModule(*this), getResolverAttr());
+  auto resolver = dyn_cast<LLVMFuncOp>(symbol);
+  if (!resolver) {
+    // FIXME: Strip aliases to find the called function
+    if (isa<AliasOp>(symbol))
+      return success();
+    return emitOpError("must have a function resolver");
+  }
+  // This matches LLVM IR verification logic, see from llvm/lib/IR/Verifier.cpp
----------------
gysit wrote:

```suggestion
  // This matches LLVM IR verification logic, see llvm/lib/IR/Verifier.cpp
```
nit: sorry that was probably my fish.

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


More information about the Mlir-commits mailing list