[Mlir-commits] [mlir] 5bedd67 - [mlir] Allow overriding AbstractDenseDataFlowAnalysis::visitOperation
Tom Eccles
llvmlistbot at llvm.org
Wed Jan 4 02:23:59 PST 2023
Author: Tom Eccles
Date: 2023-01-04T10:23:40Z
New Revision: 5bedd675d741b177606dae9f13cc7c1531b6b954
URL: https://github.com/llvm/llvm-project/commit/5bedd675d741b177606dae9f13cc7c1531b6b954
DIFF: https://github.com/llvm/llvm-project/commit/5bedd675d741b177606dae9f13cc7c1531b6b954.diff
LOG: [mlir] Allow overriding AbstractDenseDataFlowAnalysis::visitOperation
AbstractDenseDataFlowAnalysis::visitOperation controls how the dataflow
analysis proceeds around control flow. In particular, conservative
assumptions are made about call operations which can prevent some
analysis from succeeding.
The motivating case for this change is https://reviews.llvm.org/D140415,
for which it is correct and necessary for the lattice to be preserved
after call operations.
Some renaming was necessary to avoid confusion with
DenseDataFlowAnalysis::visitOperation.
AbstractDenseDataFlowAnalysis::visitRegionBranchOperation and
DenseDataFlowAnalysis::visitOperationImpl are also made protected
to allow implementation of AbstractDenseDataFlowAnalysis::visitOperation,
although I did not need these to be virtual.
Differential Revision: https://reviews.llvm.org/D140879
Added:
Modified:
mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
index 32733a127ad35..9b71ae15fc22d 100644
--- a/mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
@@ -93,16 +93,11 @@ class AbstractDenseDataFlowAnalysis : public DataFlowAnalysis {
propagateIfChanged(lhs, lhs->join(rhs));
}
-private:
/// Visit an operation. If this is a call operation or region control-flow
/// operation, then the state after the execution of the operation is set by
/// control-flow or the callgraph. Otherwise, this function invokes the
/// operation transfer function.
- void visitOperation(Operation *op);
-
- /// Visit a block. The state at the start of the block is propagated from
- /// control-flow predecessors or callsites
- void visitBlock(Block *block);
+ virtual void processOperation(Operation *op);
/// Visit a program point within a region branch operation with predecessors
/// in it. This can either be an entry block of one of the regions of the
@@ -110,6 +105,11 @@ class AbstractDenseDataFlowAnalysis : public DataFlowAnalysis {
void visitRegionBranchOperation(ProgramPoint point,
RegionBranchOpInterface branch,
AbstractDenseLattice *after);
+
+private:
+ /// Visit a block. The state at the start of the block is propagated from
+ /// control-flow predecessors or callsites
+ void visitBlock(Block *block);
};
//===----------------------------------------------------------------------===//
@@ -148,7 +148,6 @@ class DenseDataFlowAnalysis : public AbstractDenseDataFlowAnalysis {
setToEntryState(static_cast<LatticeT *>(lattice));
}
-private:
/// Type-erased wrappers that convert the abstract dense lattice to a derived
/// lattice and invoke the virtual hooks operating on the derived lattice.
void visitOperationImpl(Operation *op, const AbstractDenseLattice &before,
diff --git a/mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
index c7bc02cae4b9c..6450891f7dcc7 100644
--- a/mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
@@ -20,7 +20,7 @@ using namespace mlir::dataflow;
LogicalResult AbstractDenseDataFlowAnalysis::initialize(Operation *top) {
// Visit every operation and block.
- visitOperation(top);
+ processOperation(top);
for (Region ®ion : top->getRegions()) {
for (Block &block : region) {
visitBlock(&block);
@@ -34,7 +34,7 @@ LogicalResult AbstractDenseDataFlowAnalysis::initialize(Operation *top) {
LogicalResult AbstractDenseDataFlowAnalysis::visit(ProgramPoint point) {
if (auto *op = point.dyn_cast<Operation *>())
- visitOperation(op);
+ processOperation(op);
else if (auto *block = point.dyn_cast<Block *>())
visitBlock(block);
else
@@ -42,7 +42,7 @@ LogicalResult AbstractDenseDataFlowAnalysis::visit(ProgramPoint point) {
return success();
}
-void AbstractDenseDataFlowAnalysis::visitOperation(Operation *op) {
+void AbstractDenseDataFlowAnalysis::processOperation(Operation *op) {
// If the containing block is not executable, bail out.
if (!getOrCreateFor<Executable>(op, op->getBlock())->isLive())
return;
More information about the Mlir-commits
mailing list