Skip to content

Commit

Permalink
Revert "[mlir] [dataflow] Refactoring the definition of program point…
Browse files Browse the repository at this point in the history
…s in data flow analysis (llvm#105656)"

This reverts commit b6603e1.
  • Loading branch information
MaheshRavishankar authored and nirvedhmeshram committed Sep 10, 2024
1 parent 33f1235 commit cf22797
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 237 deletions.
16 changes: 8 additions & 8 deletions mlir/include/mlir/Analysis/DataFlow/DeadCodeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ namespace dataflow {
//===----------------------------------------------------------------------===//

/// This is a simple analysis state that represents whether the associated
/// lattice anchor (either a block or a control-flow edge) is live.
/// program point (either a block or a control-flow edge) is live.
class Executable : public AnalysisState {
public:
using AnalysisState::AnalysisState;

/// Set the state of the lattice anchor to live.
/// Set the state of the program point to live.
ChangeResult setToLive();

/// Get whether the lattice anchor is live.
/// Get whether the program point is live.
bool isLive() const { return live; }

/// Print the liveness.
void print(raw_ostream &os) const override;

/// When the state of the lattice anchor is changed to live, re-invoke
/// When the state of the program point is changed to live, re-invoke
/// subscribed analyses on the operations in the block and on the block
/// itself.
void onUpdate(DataFlowSolver *solver) const override;
Expand All @@ -60,8 +60,8 @@ class Executable : public AnalysisState {
}

private:
/// Whether the lattice anchor is live. Optimistically assume that the lattice
/// anchor is dead.
/// Whether the program point is live. Optimistically assume that the program
/// point is dead.
bool live = false;

/// A set of analyses that should be updated when this state changes.
Expand Down Expand Up @@ -140,10 +140,10 @@ class PredecessorState : public AnalysisState {
// CFGEdge
//===----------------------------------------------------------------------===//

/// This lattice anchor represents a control-flow edge between a block and one
/// This program point represents a control-flow edge between a block and one
/// of its successors.
class CFGEdge
: public GenericLatticeAnchorBase<CFGEdge, std::pair<Block *, Block *>> {
: public GenericProgramPointBase<CFGEdge, std::pair<Block *, Block *>> {
public:
using Base::Base;

Expand Down
37 changes: 18 additions & 19 deletions mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,15 @@ class AbstractDenseForwardDataFlowAnalysis : public DataFlowAnalysis {
const AbstractDenseLattice &before,
AbstractDenseLattice *after) = 0;

/// Get the dense lattice after the execution of the given lattice anchor.
virtual AbstractDenseLattice *getLattice(LatticeAnchor anchor) = 0;
/// Get the dense lattice after the execution of the given program point.
virtual AbstractDenseLattice *getLattice(ProgramPoint point) = 0;

/// Get the dense lattice after the execution of the given program point and
/// add it as a dependency to a lattice anchor. That is, every time the
/// lattice after anchor is updated, the dependent program point must be
/// visited, and the newly triggered visit might update the lattice after
/// dependent.
/// add it as a dependency to a program point. That is, every time the lattice
/// after point is updated, the dependent program point must be visited, and
/// the newly triggered visit might update the lattice after dependent.
const AbstractDenseLattice *getLatticeFor(ProgramPoint dependent,
LatticeAnchor anchor);
ProgramPoint point);

/// Set the dense lattice at control flow entry point and propagate an update
/// if it changed.
Expand Down Expand Up @@ -250,9 +249,9 @@ class DenseForwardDataFlowAnalysis
}

protected:
/// Get the dense lattice on this lattice anchor.
LatticeT *getLattice(LatticeAnchor anchor) override {
return getOrCreate<LatticeT>(anchor);
/// Get the dense lattice after this program point.
LatticeT *getLattice(ProgramPoint point) override {
return getOrCreate<LatticeT>(point);
}

/// Set the dense lattice at control flow entry point and propagate an update
Expand Down Expand Up @@ -332,16 +331,16 @@ class AbstractDenseBackwardDataFlowAnalysis : public DataFlowAnalysis {
const AbstractDenseLattice &after,
AbstractDenseLattice *before) = 0;

/// Get the dense lattice before the execution of the lattice anchor. That is,
/// Get the dense lattice before the execution of the program point. That is,
/// before the execution of the given operation or after the execution of the
/// block.
virtual AbstractDenseLattice *getLattice(LatticeAnchor anchor) = 0;
virtual AbstractDenseLattice *getLattice(ProgramPoint point) = 0;

/// Get the dense lattice before the execution of the program point in
/// `anchor` and declare that the `dependent` program point must be updated
/// every time `point` is.
/// Get the dense lattice before the execution of the program point `point`
/// and declare that the `dependent` program point must be updated every time
/// `point` is.
const AbstractDenseLattice *getLatticeFor(ProgramPoint dependent,
LatticeAnchor anchor);
ProgramPoint point);

/// Set the dense lattice before at the control flow exit point and propagate
/// the update if it changed.
Expand Down Expand Up @@ -501,9 +500,9 @@ class DenseBackwardDataFlowAnalysis
}

protected:
/// Get the dense lattice at the given lattice anchor.
LatticeT *getLattice(LatticeAnchor anchor) override {
return getOrCreate<LatticeT>(anchor);
/// Get the dense lattice at the given program point.
LatticeT *getLattice(ProgramPoint point) override {
return getOrCreate<LatticeT>(point);
}

/// Set the dense lattice at control flow exit point (after the terminator)
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class IntegerRangeAnalysis
/// At an entry point, we cannot reason about interger value ranges.
void setToEntryState(IntegerValueRangeLattice *lattice) override {
propagateIfChanged(lattice, lattice->join(IntegerValueRange::getMaxRange(
lattice->getAnchor())));
lattice->getPoint())));
}

/// Visit an operation. Invoke the transfer function on each operation that
Expand Down
8 changes: 4 additions & 4 deletions mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class AbstractSparseLattice : public AnalysisState {
/// Lattices can only be created for values.
AbstractSparseLattice(Value value) : AnalysisState(value) {}

/// Return the value this lattice is located at.
Value getAnchor() const { return AnalysisState::getAnchor().get<Value>(); }
/// Return the program point this lattice is located at.
Value getPoint() const { return AnalysisState::getPoint().get<Value>(); }

/// Join the information contained in 'rhs' into this lattice. Returns
/// if the value of the lattice changed.
Expand Down Expand Up @@ -86,8 +86,8 @@ class Lattice : public AbstractSparseLattice {
public:
using AbstractSparseLattice::AbstractSparseLattice;

/// Return the value this lattice is located at.
Value getAnchor() const { return anchor.get<Value>(); }
/// Return the program point this lattice is located at.
Value getPoint() const { return point.get<Value>(); }

/// Return the value held by this lattice. This requires that the value is
/// initialized.
Expand Down
Loading

0 comments on commit cf22797

Please sign in to comment.