eliminating g++ warnings (#105520)

Eliminating g++ warnings. Mostly declaring "[[maybe_unused]]", adding
return statements where missing and fixing casts.

@rengolin

---------

Co-authored-by: Benjamin Maxwell <macdue@dueutil.tech>
Co-authored-by: Renato Golin <rengolin@systemcall.eu>
This commit is contained in:
Frank Schlimbach 2024-10-18 22:20:47 +02:00 committed by GitHub
parent b55c52c047
commit d5746d73ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 32 additions and 24 deletions

View File

@ -2849,7 +2849,7 @@ void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
if (isElf) {
MCSymbolELF *LinkedToSym = dyn_cast<MCSymbolELF>(CurrentFnSym);
int Flags = F.hasComdat() ? (unsigned)ELF::SHF_GROUP : 0;
int Flags = F.hasComdat() ? static_cast<int>(ELF::SHF_GROUP) : 0;
JumpTableSizesSection = OutContext.getELFSection(
sectionName, ELF::SHT_LLVM_JT_SIZES, Flags, 0, GroupName, F.hasComdat(),

View File

@ -84,13 +84,20 @@ check_c_compiler_flag("-Werror=mismatched-tags" C_SUPPORTS_WERROR_MISMATCHED_TAG
append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_C_FLAGS)
append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_CXX_FLAGS)
# Silence a false positive GCC -Wunused-but-set-parameter warning in constexpr
# cases, by marking SelectedCase as used. See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is
# fixed in GCC 10.
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# Silence a false positive GCC -Wunused-but-set-parameter warning in
# constexpr cases. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827
# for details
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
endif()
# Silence a false positive GCC -Wdeprecated-copy warning in cases where
# a copy operator is defined through "using" a base class copy operator.
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
check_cxx_compiler_flag("-Wno-deprecated-copy" CXX_SUPPORTS_WNO_DEPRECTAED_COPY)
append_if(CXX_SUPPORTS_WNO_DEPRECTAED_COPY "-Wno-deprecated-copy" CMAKE_CXX_FLAGS)
endif()
endif()
# Installing the headers and docs needs to depend on generating any public

View File

@ -736,6 +736,7 @@ static mlir::WalkResult unwrap(MlirWalkResult result) {
case MlirWalkResultSkip:
return mlir::WalkResult::skip();
}
llvm_unreachable("unknown result in WalkResult::unwrap");
}
void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,

View File

@ -81,6 +81,7 @@ static Operation *createLoadTileSliceIntrinsic(
break;
}
}
llvm_unreachable("unknown type in createLoadTileSliceIntrinsic");
}
/// Helper to create an arm_sme.intr.st1*.(horiz|vert)' intrinsic.
@ -125,6 +126,7 @@ static Operation *createStoreTileSliceIntrinsic(
loc, maskOp, ptr, tileId, tileSliceI32);
}
}
llvm_unreachable("unknown type in createStoreTileSliceIntrinsic");
}
IntegerAttr getTileIdOrError(arm_sme::ArmSMETileOpInterface op) {
@ -850,6 +852,7 @@ struct StreamingVLOpConversion
case arm_sme::TypeSize::Double:
return rewriter.create<arm_sme::aarch64_sme_cntsd>(loc, i64Type);
}
llvm_unreachable("unknown type size in StreamingVLOpConversion");
}();
rewriter.replaceOpWithNewOp<arith::IndexCastOp>(
streamingVlOp, rewriter.getIndexType(), intrOp->getResult(0));

View File

@ -310,6 +310,7 @@ struct ConvertIndexCmpPattern final : OpConversionPattern<CmpOp> {
case IndexCmpPredicate::ULT:
return rewriteCmpOp<spirv::ULessThanOp>(op, adaptor, rewriter);
}
llvm_unreachable("Unknown predicate in ConvertIndexCmpPattern");
}
};

View File

@ -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 = static_cast<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 = static_cast<void *>(const_cast<void **>(&sink));
return true;
}();
(void)initialized;

View File

@ -349,7 +349,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]");

View File

@ -137,6 +137,7 @@ static ArrayRef<TileMask> getMasks(ArmSMETileType type) {
case ArmSMETileType::ZAQ:
return ZA_Q_MASKS;
}
llvm_unreachable("unknown type in getMasks");
}
class TileAllocator {

View File

@ -141,7 +141,6 @@ struct ParallelComputeFunctionArgs {
BlockArgument blockSize();
ArrayRef<BlockArgument> tripCounts();
ArrayRef<BlockArgument> lowerBounds();
ArrayRef<BlockArgument> upperBounds();
ArrayRef<BlockArgument> steps();
ArrayRef<BlockArgument> captures();
@ -175,10 +174,6 @@ ArrayRef<BlockArgument> ParallelComputeFunctionArgs::lowerBounds() {
return args.drop_front(2 + 1 * numLoops).take_front(numLoops);
}
ArrayRef<BlockArgument> ParallelComputeFunctionArgs::upperBounds() {
return args.drop_front(2 + 2 * numLoops).take_front(numLoops);
}
ArrayRef<BlockArgument> ParallelComputeFunctionArgs::steps() {
return args.drop_front(2 + 3 * numLoops).take_front(numLoops);
}

View File

@ -594,6 +594,7 @@ static bool compareSameArgs(IndexCmpPredicate pred) {
case IndexCmpPredicate::ULT:
return false;
}
llvm_unreachable("unknown predicate in compareSameArgs");
}
OpFoldResult CmpOp::fold(FoldAdaptor adaptor) {

View File

@ -1045,9 +1045,8 @@ UnresolvedMaterializationRewrite::UnresolvedMaterializationRewrite(
const TypeConverter *converter, MaterializationKind kind, Type originalType)
: OperationRewrite(Kind::UnresolvedMaterialization, rewriterImpl, op),
converterAndKind(converter, kind), originalType(originalType) {
assert(!originalType ||
kind == MaterializationKind::Target &&
"original type is valid only for target materializations");
assert((!originalType || kind == MaterializationKind::Target) &&
"original type is valid only for target materializations");
rewriterImpl.unresolvedMaterializations[op] = this;
}
@ -1337,9 +1336,8 @@ Value ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
MaterializationKind kind, OpBuilder::InsertPoint ip, Location loc,
ValueRange inputs, Type outputType, Type originalType,
const TypeConverter *converter) {
assert(!originalType ||
kind == MaterializationKind::Target &&
"original type is valid only for target materializations");
assert((!originalType || kind == MaterializationKind::Target) &&
"original type is valid only for target materializations");
// Avoid materializing an unnecessary cast.
if (inputs.size() == 1 && inputs.front().getType() == outputType)

View File

@ -54,7 +54,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);

View File

@ -225,7 +225,8 @@ public:
/// 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); }