From 7f15ad0cab5a4d52f30db7a3e309a8398ea6ae05 Mon Sep 17 00:00:00 2001 From: max Date: Thu, 2 Nov 2023 15:01:57 -0500 Subject: [PATCH] [mlir] silence -Wunused-but-set-parameter --- mlir/include/mlir/IR/Attributes.h | 2 +- mlir/include/mlir/IR/OpDefinition.h | 7 ++-- mlir/include/mlir/IR/OperationSupport.h | 37 +++++++++++++------ mlir/include/mlir/IR/Types.h | 2 +- mlir/include/mlir/IR/Value.h | 2 +- mlir/include/mlir/Query/Matcher/Marshallers.h | 9 ++--- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index f433363e5dede..1ec66ce9858fb 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -405,7 +405,7 @@ struct CastInfo) { diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index bd68c27445744..5e11a93675011 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1591,7 +1591,8 @@ foldTrait(Operation *, ArrayRef, SmallVectorImpl &) { /// Given a tuple type containing a set of traits, return the result of folding /// the given operation. template -static LogicalResult foldTraits(Operation *op, ArrayRef operands, +static LogicalResult foldTraits([[maybe_unused]] Operation *op, + [[maybe_unused]] ArrayRef operands, SmallVectorImpl &results) { return success((succeeded(foldTrait(op, operands, results)) || ...)); } @@ -1627,7 +1628,7 @@ verifyTrait(Operation *) { /// Given a set of traits, return the result of verifying the given operation. template -LogicalResult verifyTraits(Operation *op) { +LogicalResult verifyTraits([[maybe_unused]] Operation *op) { return success((succeeded(verifyTrait(op)) && ...)); } @@ -1647,7 +1648,7 @@ verifyRegionTrait(Operation *) { /// Given a set of traits, return the result of verifying the regions of the /// given operation. template -LogicalResult verifyRegionTraits(Operation *op) { +LogicalResult verifyRegionTraits([[maybe_unused]] Operation *op) { return success((succeeded(verifyRegionTrait(op)) && ...)); } } // namespace op_definition_impl diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index bb3d1643e1687..759926429cd69 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -577,6 +577,7 @@ class RegisteredOperationName : public OperationName { // dictionnary of discardable attributes for now. return cast(op)->getDiscardableAttr(name); } + void setInherentAttr(Operation *op, StringAttr name, Attribute value) final { if constexpr (hasProperties) { @@ -588,20 +589,24 @@ class RegisteredOperationName : public OperationName { // dictionnary of discardable attributes for now. return cast(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(op); ConcreteOp::populateInherentAttrs(concreteOp->getContext(), concreteOp.getProperties(), attrs); } } - LogicalResult - verifyInherentAttrs(OperationName opName, NamedAttrList &attributes, - function_ref emitError) final { + + LogicalResult verifyInherentAttrs( + [[maybe_unused]] OperationName opName, NamedAttrList &attributes, + [[maybe_unused]] function_ref 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, @@ -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; if (init) @@ -624,11 +630,14 @@ class RegisteredOperationName : public OperationName { ConcreteOp::populateDefaultProperties(opName, *storage.as()); } + void deleteProperties(OpaqueProperties prop) final { prop.as()->~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()); @@ -645,7 +654,8 @@ 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(op); return ConcreteOp::getPropertiesAsAttr(concreteOp->getContext(), @@ -653,17 +663,22 @@ class RegisteredOperationName : public OperationName { } 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() == *rhs.as(); } else { return true; } } + void copyProperties(OpaqueProperties lhs, OpaqueProperties rhs) final { *lhs.as() = *rhs.as(); } - llvm::hash_code hashProperties(OpaqueProperties prop) final { + + llvm::hash_code + hashProperties([[maybe_unused]] OpaqueProperties prop) final { if constexpr (hasProperties) return ConcreteOp::computePropertiesHash(*prop.as()); diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h index 46bb733101c12..f865d29de44be 100644 --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -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) { diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index dbcc10d4f4df8..c7cda3fee9056 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -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) { diff --git a/mlir/include/mlir/Query/Matcher/Marshallers.h b/mlir/include/mlir/Query/Matcher/Marshallers.h index 6ed35ac0ddccc..d230df042aed0 100644 --- a/mlir/include/mlir/Query/Matcher/Marshallers.h +++ b/mlir/include/mlir/Query/Matcher/Marshallers.h @@ -150,11 +150,10 @@ inline bool checkArgTypeAtIndex(llvm::StringRef matcherName, // Marshaller function for fixed number of arguments template -static VariantMatcher -matcherMarshallFixedImpl(void (*matcherFunc)(), llvm::StringRef matcherName, - SourceRange nameRange, - llvm::ArrayRef args, Diagnostics *error, - std::index_sequence) { +static VariantMatcher matcherMarshallFixedImpl( + void (*matcherFunc)(), [[maybe_unused]] llvm::StringRef matcherName, + SourceRange nameRange, llvm::ArrayRef args, Diagnostics *error, + std::index_sequence) { using FuncType = ReturnType (*)(ArgTypes...); // Check if the argument count matches the expected count