-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Mark mlir::Value::isa/dyn_cast/cast/...
member functions deprecated.
#89238
Conversation
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-mlir-core Author: Christian Sigg (chsigg) ChangesSee https://mlir.llvm.org/deprecation Full diff: https://github.com/llvm/llvm-project/pull/89238.diff 4 Files Affected:
diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index cc0cee6a31183c..509a67f61c7a6a 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -50,14 +50,19 @@ class Attribute {
/// Casting utility functions. These are deprecated and will be removed,
/// please prefer using the `llvm` namespace variants instead.
template <typename... Tys>
+ [[deprecated("Use isa<U>() instead")]]
bool isa() const;
template <typename... Tys>
+ [[deprecated("Use isa_and_nonnull<U>() instead")]]
bool isa_and_nonnull() const;
template <typename U>
+ [[deprecated("Use dyn_cast<U>() instead")]]
U dyn_cast() const;
template <typename U>
+ [[deprecated("Use dyn_cast_or_null<U>() instead")]]
U dyn_cast_or_null() const;
template <typename U>
+ [[deprecated("Use cast<U>() instead")]]
U cast() const;
/// Return a unique identifier for the concrete attribute type. This is used
@@ -172,7 +177,7 @@ bool Attribute::isa() const {
template <typename... Tys>
bool Attribute::isa_and_nonnull() const {
- return llvm::isa_and_present<Tys...>(*this);
+ return llvm::isa_and_nonnull<Tys...>(*this);
}
template <typename U>
@@ -182,7 +187,7 @@ U Attribute::dyn_cast() const {
template <typename U>
U Attribute::dyn_cast_or_null() const {
- return llvm::dyn_cast_if_present<U>(*this);
+ return llvm::dyn_cast_or_null<U>(*this);
}
template <typename U>
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index d4268e804f4f7a..b7afb160743825 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -78,14 +78,17 @@ class Location {
/// Type casting utilities on the underlying location.
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 cast<U>() instead")]]
U cast() const {
return llvm::cast<U>(*this);
}
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index a89e13b625bf40..69ef27018bc1b4 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -97,14 +97,19 @@ class Type {
bool operator!() const { return impl == nullptr; }
template <typename... Tys>
+ [[deprecated("Use isa<U>() instead")]]
bool isa() const;
template <typename... Tys>
+ [[deprecated("Use isa_and_nonnull<U>() instead")]]
bool isa_and_nonnull() const;
template <typename U>
+ [[deprecated("Use dyn_cast<U>() instead")]]
U dyn_cast() const;
template <typename U>
+ [[deprecated("Use dyn_cast_or_null<U>() instead")]]
U dyn_cast_or_null() const;
template <typename U>
+ [[deprecated("Use cast<U>() instead")]]
U cast() const;
/// Return a unique identifier for the concrete type. This is used to support
@@ -323,7 +328,7 @@ bool Type::isa() const {
template <typename... Tys>
bool Type::isa_and_nonnull() const {
- return llvm::isa_and_present<Tys...>(*this);
+ return llvm::isa_and_nonnull<Tys...>(*this);
}
template <typename U>
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index a74d0faa1dfc4b..cdbc6cc374368c 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -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);
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Coincidentally I saw these yesterday and wanted to do the same patch! (but unlikely I would have got there anytime soon)
781f2c4
to
94a3d55
Compare
isa/dyn_cast/cast/...
member functions deprecated.mlir::Value::isa/dyn_cast/cast/...
member functions deprecated.
Unfortunately, I realized that the repo is not cleaned up at all yet. I limited this PR to just |
✅ With the latest revision this PR passed the C/C++ code formatter. |
94a3d55
to
1b31e44
Compare
6eab4cf
to
1177195
Compare
Flang changes LGTM. Thanks |
The msvc build failure ( |
Integrate with more recent llvm commit get in following change for downstream iree-amd-aie project: llvm/llvm-project@286bd42. API breaking changes: - Deprecate mlir::Value::isa/dyn_cast/cast/ member functions: llvm/llvm-project#89238. See also: https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Additionally, the gcc CI build broke on a missing `iree::compiler::Dialect::Stream::IR` dependency in the Torch/InputConversion plugin. Therefore, I ran the dependencies check and fixed all the ones that came up: - `Torch/InputConversion` depends on `HAL::IR` and `Stream::IR` - `Torch/torch-mlir` depends on `TorchDialectTransformsGen`, `MLIRFuncTransforms`, `MLIRGPUDialect`, `MLIRLinalgTransforms` and `MLIRVectorTransforms` - `llvm-external-projects/CAPI` depends on `MLIRLinalgTransformOps`
Bump to latest IREE. Update for deprecated `mlir::Value::isa/dyn_cast/cast/` member functions: llvm/llvm-project#89238. See also: https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443. This brings in a standalone `forallToFor` transformation which will avoid duplication in this repo: llvm/llvm-project#89636
Integrate with more recent llvm commit get in following change for downstream iree-amd-aie project: llvm/llvm-project@286bd42. API breaking changes: - Deprecate mlir::Value::isa/dyn_cast/cast/ member functions: llvm/llvm-project#89238. See also: https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Additionally, the gcc CI build broke on a missing `iree::compiler::Dialect::Stream::IR` dependency in the Torch/InputConversion plugin. Therefore, I ran the dependencies check and fixed all the ones that came up: - `Torch/InputConversion` depends on `HAL::IR` and `Stream::IR` - `Torch/torch-mlir` depends on `TorchDialectTransformsGen`, `MLIRFuncTransforms`, `MLIRGPUDialect`, `MLIRLinalgTransforms` and `MLIRVectorTransforms` - `llvm-external-projects/CAPI` depends on `MLIRLinalgTransformOps` Signed-off-by: Lubo Litchev <lubol@google.com>
See https://mlir.llvm.org/deprecation and https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443/4