[Mlir-commits] [mlir] 2abd50a - [MLIR] Mark dominance methods const

Uday Bondhugula llvmlistbot at llvm.org
Sat Apr 18 23:24:07 PDT 2020


Author: Uday Bondhugula
Date: 2020-04-19T11:53:20+05:30
New Revision: 2abd50a359b85ba81b5448a8b4e7e2ec5a47295b

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

LOG: [MLIR] Mark dominance methods const

This change is in line with MLIR's coding style
https://mlir.llvm.org/getting_started/DeveloperGuide/
and also consistent with the dominance methods in LLVM.

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

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/Dominance.h
    mlir/lib/Analysis/Dominance.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h
index 44d8e02a6670..7d6200d83331 100644
--- a/mlir/include/mlir/Analysis/Dominance.h
+++ b/mlir/include/mlir/Analysis/Dominance.h
@@ -52,7 +52,7 @@ template <bool IsPostDom> class DominanceInfoBase {
   using super = DominanceInfoBase<IsPostDom>;
 
   /// Return true if the specified block A properly dominates block B.
-  bool properlyDominates(Block *a, Block *b);
+  bool properlyDominates(Block *a, Block *b) const;
 
   /// A mapping of regions to their base dominator tree.
   DenseMap<Region *, std::unique_ptr<base>> dominanceInfos;
@@ -65,28 +65,28 @@ class DominanceInfo : public detail::DominanceInfoBase</*IsPostDom=*/false> {
   using super::super;
 
   /// Return true if operation A properly dominates operation B.
-  bool properlyDominates(Operation *a, Operation *b);
+  bool properlyDominates(Operation *a, Operation *b) const;
 
   /// Return true if operation A dominates operation B.
-  bool dominates(Operation *a, Operation *b) {
+  bool dominates(Operation *a, Operation *b) const {
     return a == b || properlyDominates(a, b);
   }
 
   /// Return true if value A properly dominates operation B.
-  bool properlyDominates(Value a, Operation *b);
+  bool properlyDominates(Value a, Operation *b) const;
 
   /// Return true if operation A dominates operation B.
-  bool dominates(Value a, Operation *b) {
+  bool dominates(Value a, Operation *b) const {
     return (Operation *)a.getDefiningOp() == b || properlyDominates(a, b);
   }
 
   /// Return true if the specified block A dominates block B.
-  bool dominates(Block *a, Block *b) {
+  bool dominates(Block *a, Block *b) const {
     return a == b || properlyDominates(a, b);
   }
 
   /// Return true if the specified block A properly dominates block B.
-  bool properlyDominates(Block *a, Block *b) {
+  bool properlyDominates(Block *a, Block *b) const {
     return super::properlyDominates(a, b);
   }
 

diff  --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp
index 1b5f4cd917a2..ed3940535a8e 100644
--- a/mlir/lib/Analysis/Dominance.cpp
+++ b/mlir/lib/Analysis/Dominance.cpp
@@ -139,7 +139,7 @@ DominanceInfoNode *DominanceInfoBase<IsPostDom>::getNode(Block *a) {
 
 /// Return true if the specified block A properly dominates block B.
 template <bool IsPostDom>
-bool DominanceInfoBase<IsPostDom>::properlyDominates(Block *a, Block *b) {
+bool DominanceInfoBase<IsPostDom>::properlyDominates(Block *a, Block *b) const {
   // A block dominates itself but does not properly dominate itself.
   if (a == b)
     return false;
@@ -184,7 +184,7 @@ template class mlir::detail::DominanceInfoBase</*IsPostDom=*/false>;
 //===----------------------------------------------------------------------===//
 
 /// Return true if operation A properly dominates operation B.
-bool DominanceInfo::properlyDominates(Operation *a, Operation *b) {
+bool DominanceInfo::properlyDominates(Operation *a, Operation *b) const {
   auto *aBlock = a->getBlock(), *bBlock = b->getBlock();
 
   // If a or b are not within a block, then a does not dominate b.
@@ -208,7 +208,7 @@ bool DominanceInfo::properlyDominates(Operation *a, Operation *b) {
 }
 
 /// Return true if value A properly dominates operation B.
-bool DominanceInfo::properlyDominates(Value a, Operation *b) {
+bool DominanceInfo::properlyDominates(Value a, Operation *b) const {
   if (auto *aOp = a.getDefiningOp()) {
     // The values defined by an operation do *not* dominate any nested
     // operations.


        


More information about the Mlir-commits mailing list