Skip to content

Commit b5c5c2b

Browse files
[DataFlow] Migrate away from PointerUnion::{is,get} (NFC) (llvm#119950)
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
1 parent 61ab36a commit b5c5c2b

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Lattice : public AbstractSparseLattice {
8787
using AbstractSparseLattice::AbstractSparseLattice;
8888

8989
/// Return the value this lattice is located at.
90-
Value getAnchor() const { return anchor.get<Value>(); }
90+
Value getAnchor() const { return cast<Value>(anchor); }
9191

9292
/// Return the value held by this lattice. This requires that the value is
9393
/// initialized.

mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ LogicalResult SparseConstantPropagation::visitOperation(
103103
lattice->join(ConstantValue(attr, op->getDialect())));
104104
} else {
105105
LLVM_DEBUG(llvm::dbgs()
106-
<< "Folded to value: " << foldResult.get<Value>() << "\n");
106+
<< "Folded to value: " << cast<Value>(foldResult) << "\n");
107107
AbstractSparseForwardDataFlowAnalysis::join(
108-
lattice, *getLatticeElement(foldResult.get<Value>()));
108+
lattice, *getLatticeElement(cast<Value>(foldResult)));
109109
}
110110
}
111111
return success();

mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void IntegerValueRangeLattice::onUpdate(DataFlowSolver *solver) const {
4343
// If the integer range can be narrowed to a constant, update the constant
4444
// value of the SSA value.
4545
std::optional<APInt> constant = getValue().getValue().getConstantValue();
46-
auto value = anchor.get<Value>();
46+
auto value = cast<Value>(anchor);
4747
auto *cv = solver->getOrCreateState<Lattice<ConstantValue>>(value);
4848
if (!constant)
4949
return solver->propagateIfChanged(
@@ -155,9 +155,8 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments(
155155
Type boundType, bool getUpper) {
156156
unsigned int width = ConstantIntRanges::getStorageBitwidth(boundType);
157157
if (loopBound.has_value()) {
158-
if (loopBound->is<Attribute>()) {
159-
if (auto bound =
160-
dyn_cast_or_null<IntegerAttr>(loopBound->get<Attribute>()))
158+
if (auto attr = dyn_cast<Attribute>(*loopBound)) {
159+
if (auto bound = dyn_cast_or_null<IntegerAttr>(attr))
161160
return bound.getValue();
162161
} else if (auto value = llvm::dyn_cast_if_present<Value>(*loopBound)) {
163162
const IntegerValueRangeLattice *lattice =

mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void AbstractSparseLattice::onUpdate(DataFlowSolver *solver) const {
3434
AnalysisState::onUpdate(solver);
3535

3636
// Push all users of the value to the queue.
37-
for (Operation *user : anchor.get<Value>().getUsers())
37+
for (Operation *user : cast<Value>(anchor).getUsers())
3838
for (DataFlowAnalysis *analysis : useDefSubscribers)
3939
solver->enqueue({solver->getProgramPointAfter(user), analysis});
4040
}

0 commit comments

Comments
 (0)