[Mlir-commits] [mlir] [mlir][Func] Extract operation-to-function utility from Query (PR #174103)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Jan 7 00:03:27 PST 2026


================
@@ -318,3 +318,65 @@ func::lookupOrCreateFnDecl(OpBuilder &b, SymbolOpInterface symTable,
   return createFnDecl(b, symTable, funcName, funcT,
                       /*setPrivate=*/true, symbolTables);
 }
+
+func::FuncOp func::extractOperationsIntoFunction(ArrayRef<Operation *> ops,
+                                                 MLIRContext *context,
+                                                 StringRef functionName) {
+  context->loadDialect<func::FuncDialect>();
----------------
ftynse wrote:

I see this is carried over from existing code, but this is highly problematic. Dialects cannot be loaded when the context is multithreaded, which is almost always the case inside a pass, which in turn makes this function an equivalent of `assert(false)` if called from a pass, that is, most of the codebase. Let's have the load in the query tool instead.

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


More information about the Mlir-commits mailing list