[Mlir-commits] [mlir] [mlir][tosa] Converted TosaAvailability pass to ModuleOp from FuncOp, fixes crash in threaded pass manager (PR #183063)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Feb 24 06:26:23 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-tosa
Author: Arjun Bhamra (abhamra)
<details>
<summary>Changes</summary>
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.
Closes #<!-- -->182255.
---
Full diff: https://github.com/llvm/llvm-project/pull/183063.diff
1 Files Affected:
- (modified) mlir/test/lib/Dialect/Tosa/TestAvailability.cpp (+34-32)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/183063
More information about the Mlir-commits
mailing list