[Mlir-commits] [mlir] 78d6918 - [mlir] Expose region utils functions
Valentin Clement
llvmlistbot at llvm.org
Fri Nov 19 00:24:49 PST 2021
Author: Valentin Clement
Date: 2021-11-19T09:24:39+01:00
New Revision: 78d69182b7eb70e61711c805cb1956e462a29000
URL: https://github.com/llvm/llvm-project/commit/78d69182b7eb70e61711c805cb1956e462a29000
DIFF: https://github.com/llvm/llvm-project/commit/78d69182b7eb70e61711c805cb1956e462a29000.diff
LOG: [mlir] Expose region utils functions
As discussed in D109579, this patch exposes `runRegionDCE` and
`eraseUnreachableBlocks` so they can be used as separate utilities in
other passes.
Reviewed By: rriddle, mehdi_amini
Differential Revision: https://reviews.llvm.org/D114160
Added:
Modified:
mlir/include/mlir/Transforms/RegionUtils.h
mlir/lib/Transforms/Utils/RegionUtils.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h
index c87f943614e2..109b76ce2a9b 100644
--- a/mlir/include/mlir/Transforms/RegionUtils.h
+++ b/mlir/include/mlir/Transforms/RegionUtils.h
@@ -59,6 +59,16 @@ void getUsedValuesDefinedAbove(MutableArrayRef<Region> regions,
LogicalResult simplifyRegions(RewriterBase &rewriter,
MutableArrayRef<Region> regions);
+/// Erase the unreachable blocks within the provided regions. Returns success
+/// if any blocks were erased, failure otherwise.
+LogicalResult eraseUnreachableBlocks(RewriterBase &rewriter,
+ MutableArrayRef<Region> regions);
+
+/// This function returns success if any operations or arguments were deleted,
+/// failure otherwise.
+LogicalResult runRegionDCE(RewriterBase &rewriter,
+ MutableArrayRef<Region> regions);
+
} // namespace mlir
#endif // MLIR_TRANSFORMS_REGIONUTILS_H_
diff --git a/mlir/lib/Transforms/Utils/RegionUtils.cpp b/mlir/lib/Transforms/Utils/RegionUtils.cpp
index 26868d17a66e..d7d8661989b2 100644
--- a/mlir/lib/Transforms/Utils/RegionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/RegionUtils.cpp
@@ -76,8 +76,8 @@ void mlir::getUsedValuesDefinedAbove(MutableArrayRef<Region> regions,
/// Erase the unreachable blocks within the provided regions. Returns success
/// if any blocks were erased, failure otherwise.
// TODO: We could likely merge this with the DCE algorithm below.
-static LogicalResult eraseUnreachableBlocks(RewriterBase &rewriter,
- MutableArrayRef<Region> regions) {
+LogicalResult mlir::eraseUnreachableBlocks(RewriterBase &rewriter,
+ MutableArrayRef<Region> regions) {
// Set of blocks found to be reachable within a given region.
llvm::df_iterator_default_set<Block *, 16> reachable;
// If any blocks were found to be dead.
@@ -364,8 +364,8 @@ static LogicalResult deleteDeadness(RewriterBase &rewriter,
//
// This function returns success if any operations or arguments were deleted,
// failure otherwise.
-static LogicalResult runRegionDCE(RewriterBase &rewriter,
- MutableArrayRef<Region> regions) {
+LogicalResult mlir::runRegionDCE(RewriterBase &rewriter,
+ MutableArrayRef<Region> regions) {
LiveMap liveMap;
do {
liveMap.resetChanged();
More information about the Mlir-commits
mailing list