Skip to content

Commit 57b2679

Browse files
authored
Mark mlir::Value::isa/dyn_cast/cast/... member functions deprecated. (#89238)
See https://mlir.llvm.org/deprecation and https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443/4
1 parent 57c24eb commit 57b2679

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

flang/lib/Optimizer/Analysis/AliasAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace mlir;
2929
//===----------------------------------------------------------------------===//
3030

3131
static bool isDummyArgument(mlir::Value v) {
32-
auto blockArg{v.dyn_cast<mlir::BlockArgument>()};
32+
auto blockArg{mlir::dyn_cast<mlir::BlockArgument>(v)};
3333
if (!blockArg)
3434
return false;
3535

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ mlir::ParseResult fir::DoLoopOp::parse(mlir::OpAsmParser &parser,
21652165
}
21662166

21672167
fir::DoLoopOp fir::getForInductionVarOwner(mlir::Value val) {
2168-
auto ivArg = val.dyn_cast<mlir::BlockArgument>();
2168+
auto ivArg = mlir::dyn_cast<mlir::BlockArgument>(val);
21692169
if (!ivArg)
21702170
return {};
21712171
assert(ivArg.getOwner() && "unlinked block argument");
@@ -3777,7 +3777,7 @@ valueCheckFirAttributes(mlir::Value value,
37773777
if (auto loadOp = mlir::dyn_cast<fir::LoadOp>(definingOp))
37783778
value = loadOp.getMemref();
37793779
// If this is a function argument, look in the argument attributes.
3780-
if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) {
3780+
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(value)) {
37813781
if (blockArg.getOwner() && blockArg.getOwner()->isEntryBlock())
37823782
if (auto funcOp = mlir::dyn_cast<mlir::func::FuncOp>(
37833783
blockArg.getOwner()->getParentOp()))

flang/lib/Optimizer/Transforms/AffinePromotion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct AffineFunctionAnalysis {
6363
} // namespace
6464

6565
static bool analyzeCoordinate(mlir::Value coordinate, mlir::Operation *op) {
66-
if (auto blockArg = coordinate.dyn_cast<mlir::BlockArgument>()) {
66+
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(coordinate)) {
6767
if (isa<fir::DoLoopOp>(blockArg.getOwner()->getParentOp()))
6868
return true;
6969
LLVM_DEBUG(llvm::dbgs() << "AffineLoopAnalysis: array coordinate is not a "
@@ -224,7 +224,7 @@ struct AffineIfCondition {
224224
if (auto op = value.getDefiningOp<mlir::arith::ConstantOp>())
225225
if (auto intConstant = op.getValue().dyn_cast<IntegerAttr>())
226226
return toAffineExpr(intConstant.getInt());
227-
if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) {
227+
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(value)) {
228228
affineArgs.push_back(value);
229229
if (isa<fir::DoLoopOp>(blockArg.getOwner()->getParentOp()) ||
230230
isa<mlir::affine::AffineForOp>(blockArg.getOwner()->getParentOp()))

flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class ReachCollector {
187187
LLVM_DEBUG(llvm::dbgs() << "popset: " << *op << '\n');
188188
auto popFn = [&](auto rop) {
189189
assert(val && "op must have a result value");
190-
auto resNum = val.cast<mlir::OpResult>().getResultNumber();
190+
auto resNum = mlir::cast<mlir::OpResult>(val).getResultNumber();
191191
llvm::SmallVector<mlir::Value> results;
192192
rop.resultToSourceOps(results, resNum);
193193
for (auto u : results)
@@ -296,7 +296,7 @@ class ReachCollector {
296296
visited.insert(val);
297297

298298
// Process a block argument.
299-
if (auto ba = val.dyn_cast<mlir::BlockArgument>()) {
299+
if (auto ba = mlir::dyn_cast<mlir::BlockArgument>(val)) {
300300
collectArrayMentionFrom(ba);
301301
return;
302302
}

mlir/include/mlir/IR/Value.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,25 @@ class Value {
9898
constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}
9999

100100
template <typename U>
101+
[[deprecated("Use isa<U>() instead")]]
101102
bool isa() const {
102103
return llvm::isa<U>(*this);
103104
}
104105

105106
template <typename U>
107+
[[deprecated("Use dyn_cast<U>() instead")]]
106108
U dyn_cast() const {
107109
return llvm::dyn_cast<U>(*this);
108110
}
109111

110112
template <typename U>
113+
[[deprecated("Use dyn_cast_or_null<U>() instead")]]
111114
U dyn_cast_or_null() const {
112-
return llvm::dyn_cast_if_present<U>(*this);
115+
return llvm::dyn_cast_or_null<U>(*this);
113116
}
114117

115118
template <typename U>
119+
[[deprecated("Use cast<U>() instead")]]
116120
U cast() const {
117121
return llvm::cast<U>(*this);
118122
}

0 commit comments

Comments
 (0)