-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[mlir][Affine] Fix crash in affine-loop-fusion pass by guarding against an empty op list #144841
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-mlir-affine Author: Ayokunle Amodu (ayokunle321) ChangesRelated: #139231 This patch fixes a crash in the affine-loop-fusion pass when The function expects at least one op to analyze, and passing an empty array of ops causes an assertion failure. This change ensures the pass checks for an empty op array before calling @bondhugula @matthias-springer Full diff: https://github.com/llvm/llvm-project/pull/144841.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
index 4b4eb9ce37b4c..5c5d041ed6bdc 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
@@ -997,6 +997,8 @@ struct GreedyFusion {
if (producerConsumerMemrefs.count(
cast<AffineWriteOpInterface>(op).getMemRef()))
dstMemrefOps.push_back(op);
+ if (dstMemrefOps.size() == 0)
+ continue;
unsigned dstLoopDepthTest =
getInnermostCommonLoopDepth(dstMemrefOps) - numSurroundingLoops;
|
@llvm/pr-subscribers-mlir Author: Ayokunle Amodu (ayokunle321) ChangesRelated: #139231 This patch fixes a crash in the affine-loop-fusion pass when The function expects at least one op to analyze, and passing an empty array of ops causes an assertion failure. This change ensures the pass checks for an empty op array before calling @bondhugula @matthias-springer Full diff: https://github.com/llvm/llvm-project/pull/144841.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
index 4b4eb9ce37b4c..5c5d041ed6bdc 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
@@ -997,6 +997,8 @@ struct GreedyFusion {
if (producerConsumerMemrefs.count(
cast<AffineWriteOpInterface>(op).getMemRef()))
dstMemrefOps.push_back(op);
+ if (dstMemrefOps.size() == 0)
+ continue;
unsigned dstLoopDepthTest =
getInnermostCommonLoopDepth(dstMemrefOps) - numSurroundingLoops;
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test and reupload with a proper email address as instructed.
@@ -997,6 +997,8 @@ struct GreedyFusion { | |||
if (producerConsumerMemrefs.count( | |||
cast<AffineWriteOpInterface>(op).getMemRef())) | |||
dstMemrefOps.push_back(op); | |||
if (dstMemrefOps.size() == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy: use .empty()
instead of comparing size with 0.
Related: #139231
This patch fixes a crash in the affine-loop-fusion pass when
getInnermostCommonLoop
is called with an empty list of operations.The function expects at least one op to analyze, and passing an empty array of ops causes an assertion failure. This change ensures the pass checks for an empty op array before calling
getInnermostCommonLoop
.@bondhugula @matthias-springer