[llvm-branch-commits] [mlir] [mlir][IR][NFC] `DominanceInfo`: Minor code cleanups (PR #115430)
Matthias Springer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 7 22:55:22 PST 2024
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/115430
Remove `properlyDominatesImpl` and implement the functionality in `properlyDominates` directly.
Depends on #115413.
>From 58fbba463e7ed6bc03ad3276a4ed72b1f24d313a Mon Sep 17 00:00:00 2001
From: Matthias Springer <mspringer at nvidia.com>
Date: Fri, 8 Nov 2024 07:52:27 +0100
Subject: [PATCH] [mlir][IR][NFC] `DominanceInfo`: Minor code cleanups
---
mlir/include/mlir/IR/Dominance.h | 11 +----------
mlir/lib/IR/Dominance.cpp | 8 ++++----
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h
index 95c99bd59f7b2f..15b033ec854fde 100644
--- a/mlir/include/mlir/IR/Dominance.h
+++ b/mlir/include/mlir/IR/Dominance.h
@@ -147,9 +147,7 @@ class DominanceInfo : public detail::DominanceInfoBase</*IsPostDom=*/false> {
/// The `enclosingOpOk` flag says whether we should return true if the B op
/// is enclosed by a region on A.
bool properlyDominates(Operation *a, Operation *b,
- bool enclosingOpOk = true) const {
- return properlyDominatesImpl(a, b, enclosingOpOk);
- }
+ bool enclosingOpOk = true) const;
/// Return true if operation A dominates operation B, i.e. if A and B are the
/// same operation or A properly dominates B.
@@ -187,13 +185,6 @@ class DominanceInfo : public detail::DominanceInfoBase</*IsPostDom=*/false> {
bool properlyDominates(Block *a, Block *b) const {
return super::properlyDominates(a, b);
}
-
-private:
- // Return true if operation A properly dominates operation B. The
- /// 'enclosingOpOk' flag says whether we should return true if the b op is
- /// enclosed by a region on 'A'.
- bool properlyDominatesImpl(Operation *a, Operation *b,
- bool enclosingOpOk) const;
};
/// A class for computing basic postdominance information.
diff --git a/mlir/lib/IR/Dominance.cpp b/mlir/lib/IR/Dominance.cpp
index 31f7e7dbc925ce..bdd0febfa546e0 100644
--- a/mlir/lib/IR/Dominance.cpp
+++ b/mlir/lib/IR/Dominance.cpp
@@ -230,7 +230,7 @@ bool DominanceInfoBase<IsPostDom>::properlyDominates(Block *a, Block *b) const {
if (regionA != b->getParent()) {
b = regionA ? regionA->findAncestorBlockInRegion(*b) : nullptr;
// If we could not find a valid block b then it is a not a dominator.
- if (b == nullptr)
+ if (!b)
return false;
// Check to see if the ancestor of `b` is the same block as `a`. A properly
@@ -266,8 +266,8 @@ template class detail::DominanceInfoBase</*IsPostDom=*/false>;
/// Return true if operation `a` properly dominates operation `b`. The
/// 'enclosingOpOk' flag says whether we should return true if the `b` op is
/// enclosed by a region on 'a'.
-bool DominanceInfo::properlyDominatesImpl(Operation *a, Operation *b,
- bool enclosingOpOk) const {
+bool DominanceInfo::properlyDominates(Operation *a, Operation *b,
+ bool enclosingOpOk) const {
Block *aBlock = a->getBlock(), *bBlock = b->getBlock();
assert(aBlock && bBlock && "operations must be in a block");
@@ -319,7 +319,7 @@ bool DominanceInfo::properlyDominates(Value a, Operation *b) const {
// `a` properlyDominates `b` if the operation defining `a` properlyDominates
// `b`, but `a` does not itself enclose `b` in one of its regions.
- return properlyDominatesImpl(a.getDefiningOp(), b, /*enclosingOpOk=*/false);
+ return properlyDominates(a.getDefiningOp(), b, /*enclosingOpOk=*/false);
}
//===----------------------------------------------------------------------===//
More information about the llvm-branch-commits
mailing list