[Mlir-commits] [mlir] [mlir] Make IsInLoopPass thread-safe (PR #184036)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Mar 1 12:48:49 PST 2026
https://github.com/sweiglbosker created https://github.com/llvm/llvm-project/pull/184036
Fixes #183999
>From 5d2a66256992dfb4d224171d741d675d8572a07c Mon Sep 17 00:00:00 2001
From: Stefan Weigl-Bosker <stefan at s00.xyz>
Date: Sun, 1 Mar 2026 15:44:33 -0500
Subject: [PATCH] [mlir] Make IsInLoopPass thread-safe
---
.../LoopLikeInterface/test-block-loop.mlir | 2 +-
.../LoopLikeInterface/TestBlockInLoop.cpp | 24 ++++++++++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/mlir/test/Interfaces/LoopLikeInterface/test-block-loop.mlir b/mlir/test/Interfaces/LoopLikeInterface/test-block-loop.mlir
index 2d4a775f0e931..0c807c44eacdd 100644
--- a/mlir/test/Interfaces/LoopLikeInterface/test-block-loop.mlir
+++ b/mlir/test/Interfaces/LoopLikeInterface/test-block-loop.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s --mlir-disable-threading -test-block-is-in-loop 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -test-block-is-in-loop 2>&1 | FileCheck %s
module {
// Test function with only one bb
diff --git a/mlir/test/lib/Interfaces/LoopLikeInterface/TestBlockInLoop.cpp b/mlir/test/lib/Interfaces/LoopLikeInterface/TestBlockInLoop.cpp
index d695195064a6a..303cc37cfc1db 100644
--- a/mlir/test/lib/Interfaces/LoopLikeInterface/TestBlockInLoop.cpp
+++ b/mlir/test/lib/Interfaces/LoopLikeInterface/TestBlockInLoop.cpp
@@ -18,7 +18,7 @@ namespace {
/// This is a test pass that tests Blocks's isInLoop method by checking if each
/// block in a function is in a loop and outputing if it is
struct IsInLoopPass
- : public PassWrapper<IsInLoopPass, OperationPass<func::FuncOp>> {
+ : public PassWrapper<IsInLoopPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(IsInLoopPass)
StringRef getArgument() const final { return "test-block-is-in-loop"; }
@@ -27,16 +27,18 @@ struct IsInLoopPass
}
void runOnOperation() override {
- mlir::func::FuncOp func = getOperation();
- func.walk([](mlir::Block *block) {
- llvm::outs() << "Block is ";
- if (LoopLikeOpInterface::blockIsInLoop(block))
- llvm::outs() << "in a loop\n";
- else
- llvm::outs() << "not in a loop\n";
- block->print(llvm::outs());
- llvm::outs() << "\n";
- });
+ ModuleOp module = getOperation();
+ for (auto func : module.getOps<func::FuncOp>()) {
+ func.walk([](mlir::Block *block) {
+ llvm::outs() << "Block is ";
+ if (LoopLikeOpInterface::blockIsInLoop(block))
+ llvm::outs() << "in a loop\n";
+ else
+ llvm::outs() << "not in a loop\n";
+ block->print(llvm::outs());
+ llvm::outs() << "\n";
+ });
+ }
}
};
More information about the Mlir-commits
mailing list