[Mlir-commits] [mlir] d11abdf - [Verifier] Inline a method to simplify the code in preparation for bigger changes, NFC.

Chris Lattner llvmlistbot at llvm.org
Sat May 29 10:34:09 PDT 2021


Author: Chris Lattner
Date: 2021-05-29T10:33:27-07:00
New Revision: d11abdfd5a270c35d776a83bb9c90f9667ad114f

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

LOG: [Verifier] Inline a method to simplify the code in preparation for bigger changes, NFC.

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

Added: 
    

Modified: 
    mlir/lib/IR/Verifier.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Verifier.cpp b/mlir/lib/IR/Verifier.cpp
index 09daf4261f1ed..72c3c25a8fd0d 100644
--- a/mlir/lib/IR/Verifier.cpp
+++ b/mlir/lib/IR/Verifier.cpp
@@ -52,9 +52,6 @@ class OperationVerifier {
   LogicalResult verifyBlock(Block &block);
   LogicalResult verifyOperation(Operation &op);
 
-  /// Verify the dominance property of operations within the given Region.
-  LogicalResult verifyDominance(Region &region);
-
   /// Verify the dominance property of regions contained within the given
   /// Operation.
   LogicalResult verifyDominanceOfContainedRegions(Operation &op);
@@ -302,41 +299,36 @@ static void diagnoseInvalidOperandDominance(Operation &op, unsigned operandNo) {
     note << " neither in a parent nor in a child region)";
 }
 
-LogicalResult OperationVerifier::verifyDominance(Region &region) {
-  // Verify the dominance of each of the held operations.
-  for (Block &block : region) {
-    // Dominance is only meaningful inside reachable blocks.
-    bool isReachable = domInfo->isReachableFromEntry(&block);
-
-    for (Operation &op : block) {
-      if (isReachable) {
-        // Check that operands properly dominate this use.
-        for (unsigned operandNo = 0, e = op.getNumOperands(); operandNo != e;
-             ++operandNo) {
-          if (domInfo->properlyDominates(op.getOperand(operandNo), &op))
-            continue;
-
-          diagnoseInvalidOperandDominance(op, operandNo);
-          return failure();
-        }
-      }
-
-      // Recursively verify dominance within each operation in the
-      // block, even if the block itself is not reachable, or we are in
-      // a region which doesn't respect dominance.
-      if (failed(verifyDominanceOfContainedRegions(op)))
-        return failure();
-    }
-  }
-  return success();
-}
-
 /// Verify the dominance of each of the nested blocks within the given operation
 LogicalResult
 OperationVerifier::verifyDominanceOfContainedRegions(Operation &op) {
   for (Region &region : op.getRegions()) {
-    if (failed(verifyDominance(region)))
-      return failure();
+    // Verify the dominance of each of the held operations.
+    for (Block &block : region) {
+      // Dominance is only meaningful inside reachable blocks.
+      bool isReachable = domInfo->isReachableFromEntry(&block);
+
+      for (Operation &op : block) {
+        if (isReachable) {
+          // Check that operands properly dominate this use.
+          for (unsigned operandNo = 0, e = op.getNumOperands(); operandNo != e;
+               ++operandNo) {
+            if (domInfo->properlyDominates(op.getOperand(operandNo), &op))
+              continue;
+
+            diagnoseInvalidOperandDominance(op, operandNo);
+            return failure();
+          }
+        }
+
+        // Recursively verify dominance within each operation in the
+        // block, even if the block itself is not reachable, or we are in
+        // a region which doesn't respect dominance.
+        if (op.getNumRegions() != 0)
+          if (failed(verifyDominanceOfContainedRegions(op)))
+            return failure();
+      }
+    }
   }
   return success();
 }


        


More information about the Mlir-commits mailing list