[MLIR] Make test-block-is-in-loop pass a module pass (#184036)

This pass can't run in parallel on function as it would trigger race conditions.

Fixes #183999
This commit is contained in:
sweiglbosker 2026-03-03 07:09:00 -05:00 committed by GitHub
parent a368bd4049
commit ec7f3503f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 12 deletions

View file

@ -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

View file

@ -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";
});
}
}
};