[Mlir-commits] [mlir] e199191 - [mlir][tosa] Converted TosaAvailability pass to ModuleOp from FuncOp, fixes crash in threaded pass manager (#183063)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Feb 25 08:26:54 PST 2026


Author: Arjun Bhamra
Date: 2026-02-25T16:26:49Z
New Revision: e199191708d9ca7eb291d998e1569b3e077c863d

URL: https://github.com/llvm/llvm-project/commit/e199191708d9ca7eb291d998e1569b3e077c863d
DIFF: https://github.com/llvm/llvm-project/commit/e199191708d9ca7eb291d998e1569b3e077c863d.diff

LOG: [mlir][tosa] Converted TosaAvailability pass to ModuleOp from FuncOp, fixes crash in threaded pass manager (#183063)

The `TosaAvailability` pass originally worked on a per function basis
and was automatically threaded, however it used llvm::outs() which
involves the thread-unsafe `raw_ostream`.

To fix this, we convert the pass into a pass over `ModuleOp` instead of
`FuncOp`s, and iterate sequentially over all functions instead. This
removes all threading and we no longer require `-mlir-disable-threading`
which is mentioned in TosaAvailability's `availability.mlir` test.

Closes #182255.

Added: 
    

Modified: 
    mlir/test/Dialect/Tosa/availability.mlir
    mlir/test/lib/Dialect/Tosa/TestAvailability.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/Tosa/availability.mlir b/mlir/test/Dialect/Tosa/availability.mlir
index d87a041648630..8f44ca06d804a 100644
--- a/mlir/test/Dialect/Tosa/availability.mlir
+++ b/mlir/test/Dialect/Tosa/availability.mlir
@@ -3,7 +3,7 @@
 // The data type of arguments of operation are irrelevant in this test.
 //--------------------------------------------------------------------------------------------------
 
-// RUN: mlir-opt -mlir-disable-threading -test-tosa-op-availability %s | FileCheck %s
+// RUN: mlir-opt -test-tosa-op-availability %s | FileCheck %s
 
 // -----
 // CHECK-LABEL: argmax

diff  --git a/mlir/test/lib/Dialect/Tosa/TestAvailability.cpp b/mlir/test/lib/Dialect/Tosa/TestAvailability.cpp
index bec563d1ec747..ce18a936d32d2 100644
--- a/mlir/test/lib/Dialect/Tosa/TestAvailability.cpp
+++ b/mlir/test/lib/Dialect/Tosa/TestAvailability.cpp
@@ -19,7 +19,7 @@ using namespace mlir;
 namespace {
 /// A pass for testing Tosa op availability.
 struct PrintOpAvailability
-    : public PassWrapper<PrintOpAvailability, OperationPass<func::FuncOp>> {
+    : public PassWrapper<PrintOpAvailability, OperationPass<ModuleOp>> {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PrintOpAvailability)
 
   void runOnOperation() override;
@@ -29,46 +29,48 @@ struct PrintOpAvailability
 } // namespace
 
 void PrintOpAvailability::runOnOperation() {
-  auto f = getOperation();
-  llvm::outs() << f.getName() << "\n";
+  auto module = getOperation();
+  for (auto f : module.getOps<func::FuncOp>()) {
+    llvm::outs() << f.getName() << "\n";
 
-  Dialect *tosaDialect = getContext().getLoadedDialect("tosa");
+    Dialect *tosaDialect = getContext().getLoadedDialect("tosa");
 
-  f->walk([&](Operation *op) {
-    if (op->getDialect() != tosaDialect)
-      return WalkResult::advance();
+    f->walk([&](Operation *op) {
+      if (op->getDialect() != tosaDialect)
+        return WalkResult::advance();
 
-    auto opName = op->getName();
-    auto &os = llvm::outs();
+      auto opName = op->getName();
+      auto &os = llvm::outs();
 
-    if (auto profile = dyn_cast<tosa::QueryProfileInterface>(op)) {
-      os << opName << " profiles: [";
-      for (const auto &profs : profile.getProfiles()) {
-        os << " [";
-        llvm::interleaveComma(profs, os, [&](tosa::Profile prof) {
-          os << tosa::stringifyProfile(prof);
-        });
-        os << "]";
+      if (auto profile = dyn_cast<tosa::QueryProfileInterface>(op)) {
+        os << opName << " profiles: [";
+        for (const auto &profs : profile.getProfiles()) {
+          os << " [";
+          llvm::interleaveComma(profs, os, [&](tosa::Profile prof) {
+            os << tosa::stringifyProfile(prof);
+          });
+          os << "]";
+        }
+        os << " ]\n";
       }
-      os << " ]\n";
-    }
 
-    if (auto extension = dyn_cast<tosa::QueryExtensionInterface>(op)) {
-      os << opName << " extensions: [";
-      for (const auto &exts : extension.getExtensions()) {
-        os << " [";
-        llvm::interleaveComma(exts, os, [&](tosa::Extension ext) {
-          os << tosa::stringifyExtension(ext);
-        });
-        os << "]";
+      if (auto extension = dyn_cast<tosa::QueryExtensionInterface>(op)) {
+        os << opName << " extensions: [";
+        for (const auto &exts : extension.getExtensions()) {
+          os << " [";
+          llvm::interleaveComma(exts, os, [&](tosa::Extension ext) {
+            os << tosa::stringifyExtension(ext);
+          });
+          os << "]";
+        }
+        os << " ]\n";
       }
-      os << " ]\n";
-    }
 
-    os.flush();
+      os.flush();
 
-    return WalkResult::advance();
-  });
+      return WalkResult::advance();
+    });
+  }
 }
 
 namespace mlir {


        


More information about the Mlir-commits mailing list