Skip to content

Commit b487188

Browse files
authored
Add missing inline keyword to always_inline functions (#1510)
GCC requires both [[gnu::always_inline]] and the inline keyword, otherwise it warns "function might not be inlinable". The functions were already being inlined. This was silenced by the -Wno-attributes warning, now tuned to ignore only attributes with known vendor prefixes.
1 parent 06adc75 commit b487188

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ if(CABLE_COMPILER_GNULIKE)
5353
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
5454
$<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-field-initializers>
5555

56-
$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>
56+
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>>:-Wno-attributes=clang::>
57+
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>>:-Wno-attributes=msvc::>
58+
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,12>>:-Wno-attributes>
5759
$<$<CXX_COMPILER_ID:GNU>:-Wduplicated-cond>
5860
$<$<CXX_COMPILER_ID:GNU>:-Wlogical-op>
5961

lib/evmone_precompiles/blake2b.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ inline uint64_t rotr(uint64_t x, unsigned r) noexcept
2121
/// The G primitive function mixes two input words, "x" and "y", into
2222
/// four words indexed by "a", "b", "c", and "d" in the working vector v[0..15].
2323
[[gnu::always_inline, clang::no_sanitize("coverage"), clang::no_sanitize("undefined")]]
24-
void g(uint64_t v[16], size_t a, size_t b, size_t c, size_t d, uint64_t x, uint64_t y) noexcept
24+
inline void g(
25+
uint64_t v[16], size_t a, size_t b, size_t c, size_t d, uint64_t x, uint64_t y) noexcept
2526
{
2627
v[a] = v[a] + v[b] + x;
2728
v[d] = rotr(v[d] ^ v[a], 32);

lib/evmone_precompiles/modexp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ void mul_amm(std::span<uint64_t, N> r, std::span<const uint64_t, N> x,
361361
/// Almost Montgomery Multiplication specialized for 4-word (256-bit) operands.
362362
/// Delegates to mul_amm_256 in mulmod.cpp.
363363
template <>
364-
[[gnu::always_inline]] void mul_amm<4>(std::span<uint64_t, 4> r, std::span<const uint64_t, 4> x,
365-
std::span<const uint64_t, 4> y, std::span<const uint64_t, 4> mod, uint64_t mod_inv) noexcept
364+
[[gnu::always_inline]] inline void mul_amm<4>(std::span<uint64_t, 4> r,
365+
std::span<const uint64_t, 4> x, std::span<const uint64_t, 4> y,
366+
std::span<const uint64_t, 4> mod, uint64_t mod_inv) noexcept
366367
{
367368
mul_amm_256(r, x, y, mod, mod_inv);
368369
}

lib/evmone_precompiles/sha256.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static bool calc_chunk(uint8_t chunk[CHUNK_SIZE], struct BufferState* state)
135135
return true;
136136
}
137137

138-
[[gnu::always_inline, msvc::forceinline]] static void sha_256_implementation(
138+
[[gnu::always_inline, msvc::forceinline]] static inline void sha_256_implementation(
139139
uint32_t h[8], const std::byte* input, size_t len)
140140
{
141141
/*
@@ -251,7 +251,7 @@ __attribute__((target("bmi,bmi2"))) static void sha_256_x86_bmi(
251251
sha_256_implementation(h, input, len);
252252
}
253253

254-
[[gnu::always_inline]] static __m128i set(uint64_t a, uint64_t b) noexcept
254+
[[gnu::always_inline]] static inline __m128i set(uint64_t a, uint64_t b) noexcept
255255
{
256256
// NOLINTNEXTLINE(*-runtime-int)
257257
return _mm_set_epi64x(static_cast<long long>(a), static_cast<long long>(b));

0 commit comments

Comments
 (0)