Skip to content

[MLIR][Operation] Fix isBeforeInBlock crash bug mentioned in https://github.com/llvm/llvm-project/issues/60909 #101172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/lib/IR/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void Operation::updateOrderIfNecessary() {
assert(block && "expected valid parent");

// If the order is valid for this operation there is nothing to do.
if (hasValidOrder())
if (hasValidOrder() || llvm::hasSingleElement(*block))
return;
Operation *blockFront = &block->front();
Operation *blockBack = &block->back();
Expand Down
20 changes: 20 additions & 0 deletions mlir/test/Pass/scf-to-cf-and-print-liveness.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-scf-to-cf), func.func(test-print-liveness))"

module {
func.func @for_if_for(%arg0: index, %arg1: index, %arg2: index, %arg3: i1) {
%cst = arith.constant dense<0.000000e+00> : tensor<128x32xf16>
%0 = scf.for %arg4 = %arg0 to %arg1 step %arg2 iter_args(%arg5 = %cst) -> (tensor<128x32xf16>) {
%1 = scf.if %arg3 -> (tensor<128x32xf16>) {
scf.yield %arg5 : tensor<128x32xf16>
} else {
%2 = scf.for %arg6 = %arg0 to %arg1 step %arg2 iter_args(%arg7 = %arg5) -> (tensor<128x32xf16>) {
scf.yield %arg7 : tensor<128x32xf16>
}
scf.yield %2 : tensor<128x32xf16>
}
scf.yield %1 : tensor<128x32xf16>
}

return
}
}
Loading