Skip to content

Mark mlir::Value::isa/dyn_cast/cast/... member functions deprecated. #89238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace mlir;
//===----------------------------------------------------------------------===//

static bool isDummyArgument(mlir::Value v) {
auto blockArg{v.dyn_cast<mlir::BlockArgument>()};
auto blockArg{mlir::dyn_cast<mlir::BlockArgument>(v)};
if (!blockArg)
return false;

Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Dialect/FIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,7 @@ mlir::ParseResult fir::DoLoopOp::parse(mlir::OpAsmParser &parser,
}

fir::DoLoopOp fir::getForInductionVarOwner(mlir::Value val) {
auto ivArg = val.dyn_cast<mlir::BlockArgument>();
auto ivArg = mlir::dyn_cast<mlir::BlockArgument>(val);
if (!ivArg)
return {};
assert(ivArg.getOwner() && "unlinked block argument");
Expand Down Expand Up @@ -3777,7 +3777,7 @@ valueCheckFirAttributes(mlir::Value value,
if (auto loadOp = mlir::dyn_cast<fir::LoadOp>(definingOp))
value = loadOp.getMemref();
// If this is a function argument, look in the argument attributes.
if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) {
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(value)) {
if (blockArg.getOwner() && blockArg.getOwner()->isEntryBlock())
if (auto funcOp = mlir::dyn_cast<mlir::func::FuncOp>(
blockArg.getOwner()->getParentOp()))
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Transforms/AffinePromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct AffineFunctionAnalysis {
} // namespace

static bool analyzeCoordinate(mlir::Value coordinate, mlir::Operation *op) {
if (auto blockArg = coordinate.dyn_cast<mlir::BlockArgument>()) {
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(coordinate)) {
if (isa<fir::DoLoopOp>(blockArg.getOwner()->getParentOp()))
return true;
LLVM_DEBUG(llvm::dbgs() << "AffineLoopAnalysis: array coordinate is not a "
Expand Down Expand Up @@ -224,7 +224,7 @@ struct AffineIfCondition {
if (auto op = value.getDefiningOp<mlir::arith::ConstantOp>())
if (auto intConstant = op.getValue().dyn_cast<IntegerAttr>())
return toAffineExpr(intConstant.getInt());
if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) {
if (auto blockArg = mlir::dyn_cast<mlir::BlockArgument>(value)) {
affineArgs.push_back(value);
if (isa<fir::DoLoopOp>(blockArg.getOwner()->getParentOp()) ||
isa<mlir::affine::AffineForOp>(blockArg.getOwner()->getParentOp()))
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ReachCollector {
LLVM_DEBUG(llvm::dbgs() << "popset: " << *op << '\n');
auto popFn = [&](auto rop) {
assert(val && "op must have a result value");
auto resNum = val.cast<mlir::OpResult>().getResultNumber();
auto resNum = mlir::cast<mlir::OpResult>(val).getResultNumber();
llvm::SmallVector<mlir::Value> results;
rop.resultToSourceOps(results, resNum);
for (auto u : results)
Expand Down Expand Up @@ -296,7 +296,7 @@ class ReachCollector {
visited.insert(val);

// Process a block argument.
if (auto ba = val.dyn_cast<mlir::BlockArgument>()) {
if (auto ba = mlir::dyn_cast<mlir::BlockArgument>(val)) {
collectArrayMentionFrom(ba);
return;
}
Expand Down
6 changes: 5 additions & 1 deletion mlir/include/mlir/IR/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,25 @@ class Value {
constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}

template <typename U>
[[deprecated("Use isa<U>() instead")]]
bool isa() const {
return llvm::isa<U>(*this);
}

template <typename U>
[[deprecated("Use dyn_cast<U>() instead")]]
U dyn_cast() const {
return llvm::dyn_cast<U>(*this);
}

template <typename U>
[[deprecated("Use dyn_cast_or_null<U>() instead")]]
U dyn_cast_or_null() const {
return llvm::dyn_cast_if_present<U>(*this);
return llvm::dyn_cast_or_null<U>(*this);
}

template <typename U>
[[deprecated("Use cast<U>() instead")]]
U cast() const {
return llvm::cast<U>(*this);
}
Expand Down
Loading