From b38b5a73b2eb7995d9d5c4f6806fd9223b3a6f5e Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Thu, 18 Jun 2026 13:36:55 -0500 Subject: [PATCH 1/3] Fix clang unroll warning in LEB128 helpers --- include/sysio/vm/leb128.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/include/sysio/vm/leb128.hpp b/include/sysio/vm/leb128.hpp index a4bc8b9..a19aff2 100644 --- a/include/sysio/vm/leb128.hpp +++ b/include/sysio/vm/leb128.hpp @@ -37,9 +37,7 @@ namespace sysio { namespace vm { inline constexpr void from(uint32_t v) { bytes_used = 0; -#ifdef __clang__ -#pragma unroll -#elif defined(__GNUC__) +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC unroll 5 #endif for (; bytes_used < bytes_needed(); bytes_used++) { @@ -83,9 +81,7 @@ namespace sysio { namespace vm { inline constexpr uint32_t to() { uint32_t ret = 0; -#ifdef __clang__ -#pragma unroll -#elif defined(__GNUC__) +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC unroll 5 #endif for (int i=bytes_used-1; i >= 0; i--) { @@ -180,9 +176,7 @@ namespace sysio { namespace vm { inline constexpr void _from(T v) { bytes_used = 0; -#ifdef __clang__ -#pragma unroll -#elif defined(__GNUC__) +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC unroll 5 #endif for (; bytes_used < bytes_needed(); bytes_used++) { @@ -199,9 +193,7 @@ namespace sysio { namespace vm { inline constexpr T _to() { typename std::make_unsigned::type ret = 0; -#ifdef __clang__ -#pragma unroll -#elif defined(__GNUC__) +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC unroll 5 #endif for (int i=bytes_used-1; i >= 0; i--) { From f5c6420987888a5929a45d0f847623e6e8226e0c Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Thu, 18 Jun 2026 14:07:54 -0500 Subject: [PATCH 2/3] Use #pragma clang loop unroll_count(5) instead of dropping the hint Bare #pragma unroll forces a full unroll, which fails on these break-bounded loops and triggers -Wpass-failed=transform-warning. unroll_count(5) requests a partial unroll with a runtime remainder fallback, avoiding the warning while keeping an unroll hint for Clang (symmetric with GCC's #pragma GCC unroll 5). Verified with Homebrew llvm@18 (-O2/-O3 -Wall): warning gone. Full release build and ctest (5151/5151) pass. Co-Authored-By: Claude Sonnet 4.6 --- include/sysio/vm/leb128.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/sysio/vm/leb128.hpp b/include/sysio/vm/leb128.hpp index a19aff2..a52fe66 100644 --- a/include/sysio/vm/leb128.hpp +++ b/include/sysio/vm/leb128.hpp @@ -37,7 +37,9 @@ namespace sysio { namespace vm { inline constexpr void from(uint32_t v) { bytes_used = 0; -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__clang__) +#pragma clang loop unroll_count(5) +#elif defined(__GNUC__) #pragma GCC unroll 5 #endif for (; bytes_used < bytes_needed(); bytes_used++) { @@ -81,7 +83,9 @@ namespace sysio { namespace vm { inline constexpr uint32_t to() { uint32_t ret = 0; -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__clang__) +#pragma clang loop unroll_count(5) +#elif defined(__GNUC__) #pragma GCC unroll 5 #endif for (int i=bytes_used-1; i >= 0; i--) { @@ -176,7 +180,9 @@ namespace sysio { namespace vm { inline constexpr void _from(T v) { bytes_used = 0; -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__clang__) +#pragma clang loop unroll_count(5) +#elif defined(__GNUC__) #pragma GCC unroll 5 #endif for (; bytes_used < bytes_needed(); bytes_used++) { @@ -193,7 +199,9 @@ namespace sysio { namespace vm { inline constexpr T _to() { typename std::make_unsigned::type ret = 0; -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__clang__) +#pragma clang loop unroll_count(5) +#elif defined(__GNUC__) #pragma GCC unroll 5 #endif for (int i=bytes_used-1; i >= 0; i--) { From 69b9bc6d0b2216e1f5d560efc3ed0b5ffdabfd90 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Thu, 18 Jun 2026 14:10:14 -0500 Subject: [PATCH 3/3] Use #ifdef __clang__ for style consistency with the rest of the file Co-Authored-By: Claude Sonnet 4.6 --- include/sysio/vm/leb128.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sysio/vm/leb128.hpp b/include/sysio/vm/leb128.hpp index a52fe66..7b3f79b 100644 --- a/include/sysio/vm/leb128.hpp +++ b/include/sysio/vm/leb128.hpp @@ -37,7 +37,7 @@ namespace sysio { namespace vm { inline constexpr void from(uint32_t v) { bytes_used = 0; -#if defined(__clang__) +#ifdef __clang__ #pragma clang loop unroll_count(5) #elif defined(__GNUC__) #pragma GCC unroll 5 @@ -83,7 +83,7 @@ namespace sysio { namespace vm { inline constexpr uint32_t to() { uint32_t ret = 0; -#if defined(__clang__) +#ifdef __clang__ #pragma clang loop unroll_count(5) #elif defined(__GNUC__) #pragma GCC unroll 5 @@ -180,7 +180,7 @@ namespace sysio { namespace vm { inline constexpr void _from(T v) { bytes_used = 0; -#if defined(__clang__) +#ifdef __clang__ #pragma clang loop unroll_count(5) #elif defined(__GNUC__) #pragma GCC unroll 5 @@ -199,7 +199,7 @@ namespace sysio { namespace vm { inline constexpr T _to() { typename std::make_unsigned::type ret = 0; -#if defined(__clang__) +#ifdef __clang__ #pragma clang loop unroll_count(5) #elif defined(__GNUC__) #pragma GCC unroll 5