[Mlir-commits] [mlir] c02fd17 - [mlir] [scf] fix crash when conversion from scf to control flow (#107221)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 5 19:02:08 PDT 2024


Author: donald chen
Date: 2024-09-06T10:02:05+08:00
New Revision: c02fd17c1e20615c9e6174a3f8ad4ef0ec5ebbec

URL: https://github.com/llvm/llvm-project/commit/c02fd17c1e20615c9e6174a3f8ad4ef0ec5ebbec
DIFF: https://github.com/llvm/llvm-project/commit/c02fd17c1e20615c9e6174a3f8ad4ef0ec5ebbec.diff

LOG: [mlir] [scf] fix crash when conversion from scf to control flow (#107221)

This patch fixed a crash when scf.parallel's region donesn't terminate
with reduce op. This can happend in dialect conversion.

Added: 
    

Modified: 
    mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp

Removed: 
    


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