[Mlir-commits] [mlir] 787d771 - [mlir] Don't return nullptrs from scf::IfOp::getSuccessorRegions

Tres Popp llvmlistbot at llvm.org
Tue Feb 16 03:06:39 PST 2021


Author: Tres Popp
Date: 2021-02-16T12:06:30+01:00
New Revision: 787d771dce71af03bc23527ca95fcb858934ae7a

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

LOG: [mlir] Don't return nullptrs from scf::IfOp::getSuccessorRegions

Previously this might happen if there was no elseRegion and the method
was asked for all successor regions.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp
index eaaf90108f61..f8732581684a 100644
--- a/mlir/lib/Dialect/SCF/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/SCF.cpp
@@ -708,7 +708,9 @@ void IfOp::getSuccessorRegions(Optional<unsigned> index,
   } else {
     // If the condition isn't constant, both regions may be executed.
     regions.push_back(RegionSuccessor(&thenRegion()));
-    regions.push_back(RegionSuccessor(elseRegion));
+    // If the else region does not exist, it is not a viable successor.
+    if (elseRegion)
+      regions.push_back(RegionSuccessor(elseRegion));
     return;
   }
 


        


More information about the Mlir-commits mailing list