[Mlir-commits] [llvm] [mlir] eliminating g++ warnings (PR #105520)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Aug 21 06:13:35 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-sme
@llvm/pr-subscribers-mlir-async
@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-mlir-spirv
Author: Frank Schlimbach (fschlimb)
<details>
<summary>Changes</summary>
Eliminating g++ warnings. Mostly declaring "[[maybe_unused]]", adding return statements where missing and fixing casts.
@<!-- -->rengolin
---
Full diff: https://github.com/llvm/llvm-project/pull/105520.diff
15 Files Affected:
- (modified) llvm/include/llvm/BinaryFormat/MachO.h (+1-1)
- (modified) mlir/include/mlir/IR/OpDefinition.h (+4-3)
- (modified) mlir/include/mlir/Pass/Pass.h (+1)
- (modified) mlir/include/mlir/Query/Matcher/Marshallers.h (+4-5)
- (modified) mlir/lib/Analysis/FlatLinearValueConstraints.cpp (+1-1)
- (modified) mlir/lib/CAPI/IR/IR.cpp (+2)
- (modified) mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp (+6)
- (modified) mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp (+2)
- (modified) mlir/lib/Debug/DebuggerExecutionContextHook.cpp (+2-2)
- (modified) mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp (+2)
- (modified) mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp (+1)
- (modified) mlir/lib/Dialect/Index/IR/IndexOps.cpp (+2)
- (modified) mlir/unittests/Bytecode/BytecodeTest.cpp (+1-1)
- (modified) mlir/unittests/Support/CyclicReplacerCacheTest.cpp (+2-1)
``````````diff
diff --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h
index b37651e85a6269..17f30d9d0d0b23 100644
--- a/llvm/include/llvm/BinaryFormat/MachO.h
+++ b/llvm/include/llvm/BinaryFormat/MachO.h
@@ -1662,7 +1662,7 @@ CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion,
"ptrauth abi version must fit in 4 bits");
return CPU_SUBTYPE_ARM64E | CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK |
(PtrAuthKernelABIVersion ? CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK
- : 0) |
+ : static_cast<CPUSubTypeARM64>(0)) |
(PtrAuthABIVersion << 24);
}
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 59f094d6690991..1121de858aa632 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1593,7 +1593,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)) || ...));
}
@@ -1629,7 +1630,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)) && ...));
}
@@ -1649,7 +1650,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
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index 7725a3a2910bd4..e7ed0a1ac61395 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -94,6 +94,7 @@ class Pass {
Option(Pass &parent, StringRef arg, Args &&...args)
: detail::PassOptions::Option<DataType, OptionParser>(
parent.passOptions, arg, std::forward<Args>(args)...) {}
+ Option &operator=(const Option &other) = default; // gcc11
using detail::PassOptions::Option<DataType, OptionParser>::operator=;
};
/// This class represents a specific pass option that contains a list of
diff --git a/mlir/include/mlir/Query/Matcher/Marshallers.h b/mlir/include/mlir/Query/Matcher/Marshallers.h
index 6ed35ac0ddccc7..d230df042aed04 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 <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
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index e628fb152b52f8..6778029bb5ca64 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -893,7 +893,7 @@ FlatLinearValueConstraints::FlatLinearValueConstraints(IntegerSet set,
set.getNumDims(), set.getNumSymbols(),
/*numLocals=*/0) {
assert(operands.empty() ||
- set.getNumInputs() == operands.size() && "operand count mismatch");
+ (set.getNumInputs() == operands.size() && "operand count mismatch"));
// Set the values for the non-local variables.
for (unsigned i = 0, e = operands.size(); i < e; ++i)
setValue(i, operands[i]);
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index 5eb531b70aee05..eb057bcc9d5e56 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -736,6 +736,8 @@ static mlir::WalkResult unwrap(MlirWalkResult result) {
case MlirWalkResultSkip:
return mlir::WalkResult::skip();
}
+ assert("unknown result in WalkResult::unwrap" == nullptr);
+ return {};
}
void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,
diff --git a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
index 4d96091a637cf0..c44037bccd444a 100644
--- a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
+++ b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
@@ -80,6 +80,8 @@ static Operation *createLoadTileSliceIntrinsic(
break;
}
}
+ assert("unknown type in createLoadTileSliceIntrinsic" == nullptr);
+ return nullptr;
}
/// Helper to create an arm_sme.intr.st1*.(horiz|vert)' intrinsic.
@@ -124,6 +126,8 @@ static Operation *createStoreTileSliceIntrinsic(
loc, maskOp, ptr, tileId, tileSliceI32);
}
}
+ assert("unknown type in createStoreTileSliceIntrinsic" == nullptr);
+ return nullptr;
}
IntegerAttr getTileIdOrError(arm_sme::ArmSMETileOpInterface op) {
@@ -848,6 +852,8 @@ struct StreamingVLOpConversion
case arm_sme::TypeSize::Double:
return rewriter.create<arm_sme::aarch64_sme_cntsd>(loc, i64Type);
}
+ assert("unknown type in StreamingVLOpConversion" == nullptr);
+ return nullptr;
}();
rewriter.replaceOpWithNewOp<arith::IndexCastOp>(
streamingVlOp, rewriter.getIndexType(), intrOp->getResult(0));
diff --git a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
index b58efc096e2eaf..30705a23d5bb6f 100644
--- a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
+++ b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
@@ -310,6 +310,8 @@ struct ConvertIndexCmpPattern final : OpConversionPattern<CmpOp> {
case IndexCmpPredicate::ULT:
return rewriteCmpOp<spirv::ULessThanOp>(op, adaptor, rewriter);
}
+ assert("Unknown predicate in ConvertIndexCmpPattern" == nullptr);
+ return failure();
}
};
diff --git a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
index 744a0380ec710b..342888cc9cbcbe 100644
--- a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
+++ b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
@@ -301,7 +301,7 @@ void mlirDebuggerAddFileLineColLocBreakpoint(const char *file, int line,
LLVM_ATTRIBUTE_NOINLINE void mlirDebuggerBreakpointHook() {
static LLVM_THREAD_LOCAL void *volatile sink;
- sink = (void *)&sink;
+ sink = (void *)const_cast<void **>(&sink);
}
static void preventLinkerDeadCodeElim() {
@@ -321,7 +321,7 @@ static void preventLinkerDeadCodeElim() {
sink = (void *)mlirDebuggerAddTagBreakpoint;
sink = (void *)mlirDebuggerAddRewritePatternBreakpoint;
sink = (void *)mlirDebuggerAddFileLineColLocBreakpoint;
- sink = (void *)&sink;
+ sink = (void *)const_cast<void **>(&sink);
return true;
}();
(void)initialized;
diff --git a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
index c1a785fb25478d..85ea49bed1dd0d 100644
--- a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
+++ b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
@@ -347,7 +347,7 @@ LogicalResult DPPOp::verify() {
return emitOpError("quad_perm attribute must have exactly 4 elements");
}
for (auto elem : quadPermAttr.getAsRange<IntegerAttr>()) {
- uint32_t num = elem.getInt();
+ int32_t num = elem.getInt();
if (num < 0 || num > 3) {
return emitOpError(
"Each element of quad_perm must be in the range [0, 3]");
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
index 3a2042d23e5346..1ec0e3cd48863f 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
@@ -137,6 +137,8 @@ static ArrayRef<TileMask> getMasks(ArmSMETileType type) {
case ArmSMETileType::ZAQ:
return ZA_Q_MASKS;
}
+ assert("unknown type in getMasks" == nullptr);
+ return {};
}
class TileAllocator {
diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index 8c3e25355f6087..1db38232e77fe7 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -175,6 +175,7 @@ ArrayRef<BlockArgument> ParallelComputeFunctionArgs::lowerBounds() {
return args.drop_front(2 + 1 * numLoops).take_front(numLoops);
}
+[[maybe_unused]]
ArrayRef<BlockArgument> ParallelComputeFunctionArgs::upperBounds() {
return args.drop_front(2 + 2 * numLoops).take_front(numLoops);
}
diff --git a/mlir/lib/Dialect/Index/IR/IndexOps.cpp b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
index 42401dae217ce1..cb5f48f2d603ad 100644
--- a/mlir/lib/Dialect/Index/IR/IndexOps.cpp
+++ b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
@@ -594,6 +594,8 @@ static bool compareSameArgs(IndexCmpPredicate pred) {
case IndexCmpPredicate::ULT:
return false;
}
+ assert("unknown predicate in compareSameArgs" == nullptr);
+ return {};
}
OpFoldResult CmpOp::fold(FoldAdaptor adaptor) {
diff --git a/mlir/unittests/Bytecode/BytecodeTest.cpp b/mlir/unittests/Bytecode/BytecodeTest.cpp
index a37a2afc226453..5f1f8bfd2e1758 100644
--- a/mlir/unittests/Bytecode/BytecodeTest.cpp
+++ b/mlir/unittests/Bytecode/BytecodeTest.cpp
@@ -55,7 +55,7 @@ TEST(Bytecode, MultiModuleWithResource) {
constexpr size_t kAlignment = 0x20;
size_t bufferSize = buffer.size();
buffer.reserve(bufferSize + kAlignment - 1);
- size_t pad = ~(uintptr_t)buffer.data() + 1 & kAlignment - 1;
+ size_t pad = (~(uintptr_t)buffer.data() + 1) & (kAlignment - 1);
buffer.insert(0, pad, ' ');
StringRef alignedBuffer(buffer.data() + pad, bufferSize);
diff --git a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
index 64a8ab72b69b7d..26f0709f7d8310 100644
--- a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
+++ b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
@@ -225,7 +225,8 @@ class CachedCyclicReplacerGraphReplacement : public ::testing::Test {
/// Add a recursive-self-node, i.e. a duplicate of the original node that is
/// meant to represent an indirection to it.
std::pair<Node, int64_t> addRecursiveSelfNode(Graph::Node originalId) {
- return {addNode(originalId, nextRecursionId), nextRecursionId++};
+ auto node = addNode(originalId, nextRecursionId);
+ return {node, nextRecursionId++};
}
void addEdge(Node src, Node sink) { connections.addEdge(src, sink); }
``````````
</details>
https://github.com/llvm/llvm-project/pull/105520
More information about the Mlir-commits
mailing list