[Mlir-commits] [mlir] [mlir] [scf] fix crash when conversion from scf to control flow (PR #107221)
donald chen
llvmlistbot at llvm.org
Wed Sep 4 04:07:21 PDT 2024
https://github.com/cxy-1993 created https://github.com/llvm/llvm-project/pull/107221
This patch fixed a crash when scf.parallel's region donesn't terminate with reduce op. This can happend in dialect conversion.
>From fb32fdc8adcf554fead24716a7edf3bda550b6f6 Mon Sep 17 00:00:00 2001
From: donald chen <chenxunyu1993 at gmail.com>
Date: Wed, 4 Sep 2024 11:03:10 +0000
Subject: [PATCH] [mlir] [scf] fix crash when conversion from scf to control
flow
This patch fixed a crash when scf.parallel's region donesn't terminate with
reduce op. This can happend in dialect conversion.
---
mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
index 2372ab5b82a772..45f3bcfa393be8 100644
--- a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
+++ b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
@@ -482,7 +482,10 @@ LogicalResult
ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
PatternRewriter &rewriter) const {
Location loc = parallelOp.getLoc();
- auto reductionOp = cast<ReduceOp>(parallelOp.getBody()->getTerminator());
+ auto reductionOp = dyn_cast<ReduceOp>(parallelOp.getBody()->getTerminator());
+ if (!reductionOp) {
+ return failure();
+ }
// For a parallel loop, we essentially need to create an n-dimensional loop
// nest. We do this by translating to scf.for ops and have those lowered in
More information about the Mlir-commits
mailing list