[Mlir-commits] [mlir] 029f1a4 - [MLIR] Address post-submit comments on scf.if's InferTypeOpInterface

Frederik Gossen llvmlistbot at llvm.org
Fri Jan 20 07:37:48 PST 2023


Author: Frederik Gossen
Date: 2023-01-20T10:37:25-05:00
New Revision: 029f1a4efd25c985fa87fdebcd0704a281d99a9f

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

LOG: [MLIR] Address post-submit comments on scf.if's InferTypeOpInterface

Differential Revision: https://reviews.llvm.org/D142155

Added: 
    

Modified: 
    mlir/lib/Dialect/SCF/IR/SCF.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 18c3e7ae10af3..b870330250418 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -1471,9 +1471,14 @@ IfOp::inferReturnTypes(MLIRContext *ctx, std::optional<Location> loc,
   if (regions.empty())
     return failure();
   Region *r = regions.front();
-  assert(!r->empty());
+  if (r->empty())
+    return failure();
   Block &b = r->front();
-  auto yieldOp = llvm::dyn_cast<YieldOp>(b.getTerminator());
+  if (b.empty())
+    return failure();
+  auto yieldOp = llvm::dyn_cast<YieldOp>(b.back());
+  if (!yieldOp)
+    return failure();
   TypeRange types = yieldOp.getOperandTypes();
   inferredReturnTypes.insert(inferredReturnTypes.end(), types.begin(),
                              types.end());


        


More information about the Mlir-commits mailing list