From 3c53bb1e20c97482f914012c9b92c23f01aa604a Mon Sep 17 00:00:00 2001 From: John Platts Date: Sat, 27 Sep 2025 09:08:49 -0500 Subject: [PATCH 1/2] Fixes for GCC compiler warnings in spin.h and thread_pool.h --- hwy/base.h | 15 +++++++++++++++ hwy/contrib/thread_pool/spin.h | 1 + hwy/contrib/thread_pool/thread_pool.h | 8 +++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hwy/base.h b/hwy/base.h index 764352a443..d6c75bbe72 100644 --- a/hwy/base.h +++ b/hwy/base.h @@ -148,6 +148,21 @@ #endif // !HWY_COMPILER_MSVC +#if (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1200) || \ + (HWY_COMPILER_ICC && !HWY_COMPILER_ICX) +// The use of __attribute__((unused)) in private class member variables triggers +// a compiler warning with GCC 11 and earlier and ICC + +// GCC 11 and earlier and ICC also do not emit -Wunused-private-field warnings +// for unused private class member variables +#define HWY_MEMBER_VAR_MAYBE_UNUSED +#else +// Clang and ICX need __attribute__((unused)) in unused private class member +// variables to suppress -Wunused-private-field warnings unless this warning is +// ignored by using HWY_DIAGNOSTICS_OFF +#define HWY_MEMBER_VAR_MAYBE_UNUSED HWY_MAYBE_UNUSED +#endif + //------------------------------------------------------------------------------ // Builtin/attributes (no more #include after this point due to namespace!) diff --git a/hwy/contrib/thread_pool/spin.h b/hwy/contrib/thread_pool/spin.h index c83e867fa9..41fb786e13 100644 --- a/hwy/contrib/thread_pool/spin.h +++ b/hwy/contrib/thread_pool/spin.h @@ -98,6 +98,7 @@ static inline const char* ToString(SpinType type) { case SpinType::kPause: return "Pause"; case SpinType::kSentinel: + default: return nullptr; } } diff --git a/hwy/contrib/thread_pool/thread_pool.h b/hwy/contrib/thread_pool/thread_pool.h index 897c22306d..3fbfc82763 100644 --- a/hwy/contrib/thread_pool/thread_pool.h +++ b/hwy/contrib/thread_pool/thread_pool.h @@ -231,7 +231,7 @@ struct Config { // 4 bytes SpinType spin_type; WaitType wait_type; - HWY_MAYBE_UNUSED uint8_t reserved[2]; + HWY_MEMBER_VAR_MAYBE_UNUSED uint8_t reserved[2]; }; static_assert(sizeof(Config) == 4, ""); @@ -352,7 +352,8 @@ class alignas(HWY_ALIGNMENT) Worker { // HWY_ALIGNMENT bytes // thread_pool_test requires nonzero epoch. uint32_t worker_epoch_ = 1; - HWY_MAYBE_UNUSED uint8_t padding_[HWY_ALIGNMENT - 64 - sizeof(victims_)]; + HWY_MEMBER_VAR_MAYBE_UNUSED uint8_t + padding_[HWY_ALIGNMENT - 64 - sizeof(victims_)]; }; static_assert(sizeof(Worker) == HWY_ALIGNMENT, ""); @@ -992,7 +993,8 @@ class alignas(HWY_ALIGNMENT) ThreadPool { // passed to `ThreadFunc`. Padding ensures that the workers' cache lines are // not unnecessarily invalidated when the main thread writes other members. alignas(HWY_ALIGNMENT) pool::Tasks tasks_; - HWY_MAYBE_UNUSED char padding_[HWY_ALIGNMENT - sizeof(pool::Tasks)]; + HWY_MEMBER_VAR_MAYBE_UNUSED char + padding_[HWY_ALIGNMENT - sizeof(pool::Tasks)]; // In debug builds, detects if functions are re-entered. std::atomic_flag busy_ = ATOMIC_FLAG_INIT; From 0913de4cffcb4707a7b32aecd7376096148f0cd4 Mon Sep 17 00:00:00 2001 From: Jan Wassenberg Date: Mon, 29 Sep 2025 04:55:08 -0700 Subject: [PATCH 2/2] SVE still broken on Clang 22 (msan fail on svcnt) PiperOrigin-RevId: 812734694 --- hwy/detect_targets.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hwy/detect_targets.h b/hwy/detect_targets.h index 25b7d826c8..d517186754 100644 --- a/hwy/detect_targets.h +++ b/hwy/detect_targets.h @@ -268,9 +268,9 @@ // SVE[2] require recent clang or gcc versions. #ifndef HWY_BROKEN_SVE // allow override -// GCC 10+. Clang 21 still has many test failures for SVE. No Apple CPU (at -// least up to and including M4 and A18) has SVE. -#if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2200) || \ +// GCC 10+. Clang 22 still has test failures for SVE, including MSAN. No Apple +// CPU (at least up to and including M4 and A18) has SVE. +#if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2300) || \ (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \ HWY_OS_APPLE #define HWY_BROKEN_SVE (HWY_SVE | HWY_SVE_256) @@ -280,8 +280,8 @@ #endif // HWY_BROKEN_SVE #ifndef HWY_BROKEN_SVE2 // allow override -// Clang 21 still has many test failures for SVE2. -#if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2200) || \ +// Clang 21 still has test failures for SVE2, including MSAN. +#if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2300) || \ (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \ HWY_OS_APPLE #define HWY_BROKEN_SVE2 (HWY_SVE2 | HWY_SVE2_128)