Skip to content

[mlir] fix -Wunused-but-set-parameter #71099

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

Closed
wants to merge 1 commit into from
Closed
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 mlir/include/mlir/IR/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ struct CastInfo<To, From,
/// returns the dynamic ID. This means that T::classof would end up comparing
/// the static TypeID of the children to the static TypeID of its parent,
/// making it impossible to downcast from the parent to the child.
static inline bool isPossible(mlir::Attribute ty) {
static inline bool isPossible([[maybe_unused]] mlir::Attribute ty) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like working around some gcc bugs? I don't think we should do that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #68667
And also: #68528 ; maybe the guard in CMake isn't wide enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well that'll teach me to not search for issues/closed PRs before submitting a new one. In reality I just need to add the same CMake lines in my downstream builds (the place I was actually recently seeing the noise). Sorry!

/// Return a constant true instead of a dynamic true when casting to self or
/// up the hierarchy.
if constexpr (std::is_base_of_v<To, From>) {
Expand Down
7 changes: 4 additions & 3 deletions mlir/include/mlir/IR/OpDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,8 @@ foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
/// Given a tuple type containing a set of traits, return the result of folding
/// the given operation.
template <typename... Ts>
static LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
static LogicalResult foldTraits([[maybe_unused]] Operation *op,
[[maybe_unused]] ArrayRef<Attribute> operands,
SmallVectorImpl<OpFoldResult> &results) {
return success((succeeded(foldTrait<Ts>(op, operands, results)) || ...));
}
Expand Down Expand Up @@ -1627,7 +1628,7 @@ verifyTrait(Operation *) {

/// Given a set of traits, return the result of verifying the given operation.
template <typename... Ts>
LogicalResult verifyTraits(Operation *op) {
LogicalResult verifyTraits([[maybe_unused]] Operation *op) {
return success((succeeded(verifyTrait<Ts>(op)) && ...));
}

Expand All @@ -1647,7 +1648,7 @@ verifyRegionTrait(Operation *) {
/// Given a set of traits, return the result of verifying the regions of the
/// given operation.
template <typename... Ts>
LogicalResult verifyRegionTraits(Operation *op) {
LogicalResult verifyRegionTraits([[maybe_unused]] Operation *op) {
return success((succeeded(verifyRegionTrait<Ts>(op)) && ...));
}
} // namespace op_definition_impl
Expand Down
37 changes: 26 additions & 11 deletions mlir/include/mlir/IR/OperationSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ class RegisteredOperationName : public OperationName {
// dictionnary of discardable attributes for now.
return cast<ConcreteOp>(op)->getDiscardableAttr(name);
}

void setInherentAttr(Operation *op, StringAttr name,
Attribute value) final {
if constexpr (hasProperties) {
Expand All @@ -588,20 +589,24 @@ class RegisteredOperationName : public OperationName {
// dictionnary of discardable attributes for now.
return cast<ConcreteOp>(op)->setDiscardableAttr(name, value);
}
void populateInherentAttrs(Operation *op, NamedAttrList &attrs) final {

void populateInherentAttrs([[maybe_unused]] Operation *op,
NamedAttrList &attrs) final {
if constexpr (hasProperties) {
auto concreteOp = cast<ConcreteOp>(op);
ConcreteOp::populateInherentAttrs(concreteOp->getContext(),
concreteOp.getProperties(), attrs);
}
}
LogicalResult
verifyInherentAttrs(OperationName opName, NamedAttrList &attributes,
function_ref<InFlightDiagnostic()> emitError) final {

LogicalResult verifyInherentAttrs(
[[maybe_unused]] OperationName opName, NamedAttrList &attributes,
[[maybe_unused]] function_ref<InFlightDiagnostic()> emitError) final {
if constexpr (hasProperties)
return ConcreteOp::verifyInherentAttrs(opName, attributes, emitError);
return success();
}

// Detect if the concrete operation defined properties.
static constexpr bool hasProperties = !std::is_same_v<
typename ConcreteOp::template InferredProperties<ConcreteOp>,
Expand All @@ -612,8 +617,9 @@ class RegisteredOperationName : public OperationName {
return sizeof(Properties);
return 0;
}
void initProperties(OperationName opName, OpaqueProperties storage,
OpaqueProperties init) final {

void initProperties([[maybe_unused]] OperationName opName,
OpaqueProperties storage, OpaqueProperties init) final {
using Properties =
typename ConcreteOp::template InferredProperties<ConcreteOp>;
if (init)
Expand All @@ -624,11 +630,14 @@ class RegisteredOperationName : public OperationName {
ConcreteOp::populateDefaultProperties(opName,
*storage.as<Properties *>());
}

void deleteProperties(OpaqueProperties prop) final {
prop.as<Properties *>()->~Properties();
}
void populateDefaultProperties(OperationName opName,
OpaqueProperties properties) final {

void populateDefaultProperties(
[[maybe_unused]] OperationName opName,
[[maybe_unused]] OpaqueProperties properties) final {
if constexpr (hasProperties)
ConcreteOp::populateDefaultProperties(opName,
*properties.as<Properties *>());
Expand All @@ -645,25 +654,31 @@ class RegisteredOperationName : public OperationName {
emitError() << "this operation does not support properties";
return failure();
}
Attribute getPropertiesAsAttr(Operation *op) final {

Attribute getPropertiesAsAttr([[maybe_unused]] Operation *op) final {
if constexpr (hasProperties) {
auto concreteOp = cast<ConcreteOp>(op);
return ConcreteOp::getPropertiesAsAttr(concreteOp->getContext(),
concreteOp.getProperties());
}
return {};
}
bool compareProperties(OpaqueProperties lhs, OpaqueProperties rhs) final {

bool compareProperties([[maybe_unused]] OpaqueProperties lhs,
[[maybe_unused]] OpaqueProperties rhs) final {
if constexpr (hasProperties) {
return *lhs.as<Properties *>() == *rhs.as<Properties *>();
} else {
return true;
}
}

void copyProperties(OpaqueProperties lhs, OpaqueProperties rhs) final {
*lhs.as<Properties *>() = *rhs.as<Properties *>();
}
llvm::hash_code hashProperties(OpaqueProperties prop) final {

llvm::hash_code
hashProperties([[maybe_unused]] OpaqueProperties prop) final {
if constexpr (hasProperties)
return ConcreteOp::computePropertiesHash(*prop.as<Properties *>());

Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ struct CastInfo<
/// ID. This means that T::classof would end up comparing the static TypeID of
/// the children to the static TypeID of its parent, making it impossible to
/// downcast from the parent to the child.
static inline bool isPossible(mlir::Type ty) {
static inline bool isPossible([[maybe_unused]] mlir::Type ty) {
/// Return a constant true instead of a dynamic true when casting to self or
/// up the hierarchy.
if constexpr (std::is_base_of_v<To, From>) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ struct CastInfo<
/// that returns the dynamic type. This means that T::classof would end up
/// comparing the static Kind of the children to the static Kind of its
/// parent, making it impossible to downcast from the parent to the child.
static inline bool isPossible(mlir::Value ty) {
static inline bool isPossible([[maybe_unused]] mlir::Value ty) {
/// Return a constant true instead of a dynamic true when casting to self or
/// up the hierarchy.
if constexpr (std::is_base_of_v<To, From>) {
Expand Down
9 changes: 4 additions & 5 deletions mlir/include/mlir/Query/Matcher/Marshallers.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ inline bool checkArgTypeAtIndex(llvm::StringRef matcherName,

// Marshaller function for fixed number of arguments
template <typename ReturnType, typename... ArgTypes, size_t... Is>
static VariantMatcher
matcherMarshallFixedImpl(void (*matcherFunc)(), llvm::StringRef matcherName,
SourceRange nameRange,
llvm::ArrayRef<ParserValue> args, Diagnostics *error,
std::index_sequence<Is...>) {
static VariantMatcher matcherMarshallFixedImpl(
void (*matcherFunc)(), [[maybe_unused]] llvm::StringRef matcherName,
SourceRange nameRange, llvm::ArrayRef<ParserValue> args, Diagnostics *error,
std::index_sequence<Is...>) {
using FuncType = ReturnType (*)(ArgTypes...);

// Check if the argument count matches the expected count
Expand Down