@@ -1375,6 +1375,23 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
13751375 */
13761376# define XXH_NO_INLINE_HINTS 0
13771377
1378+ /* !
1379+ * @def XXH3_INLINE_SECRET
1380+ * @brief Determines whether to inline the XXH3 withSecret code.
1381+ *
1382+ * When the secret size is known, the compiler can improve the performance
1383+ * of XXH3_64bits_withSecret() and XXH3_128bits_withSecret().
1384+ *
1385+ * However, if the secret size is not known, it doesn't have any benefit. This
1386+ * happens when xxHash is compiled into a global symbol. Therefore, if
1387+ * @ref XXH_INLINE_ALL is *not* defined, this will be defined to 0.
1388+ *
1389+ * Additionally, this defaults to 0 on GCC 12+, which has an issue with function pointers
1390+ * that are *sometimes* force inline on -Og, and it is impossible to automatically
1391+ * detect this optimization level.
1392+ */
1393+ # define XXH3_INLINE_SECRET 0
1394+
13781395/* !
13791396 * @def XXH32_ENDJMP
13801397 * @brief Whether to use a jump for `XXH32_finalize`.
@@ -1439,6 +1456,15 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
14391456# endif
14401457#endif
14411458
1459+ #ifndef XXH3_INLINE_SECRET
1460+ # if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) \
1461+ || !defined (XXH_INLINE_ALL)
1462+ # define XXH3_INLINE_SECRET 0
1463+ # else
1464+ # define XXH3_INLINE_SECRET 1
1465+ # endif
1466+ #endif
1467+
14421468#ifndef XXH32_ENDJMP
14431469/* generally preferable for performance */
14441470# define XXH32_ENDJMP 0
@@ -1515,6 +1541,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
15151541# define XXH_NO_INLINE static
15161542#endif
15171543
1544+ #if XXH3_INLINE_SECRET
1545+ # define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE
1546+ #else
1547+ # define XXH3_WITH_SECRET_INLINE XXH_NO_INLINE
1548+ #endif
15181549
15191550
15201551/* *************************************
@@ -4465,7 +4496,7 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len,
44654496 * so that the compiler can properly optimize the vectorized loop.
44664497 * This makes a big performance difference for "medium" keys (<1 KB) when using AVX instruction set.
44674498 */
4468- XXH_FORCE_INLINE XXH64_hash_t
4499+ XXH3_WITH_SECRET_INLINE XXH64_hash_t
44694500XXH3_hashLong_64b_withSecret (const void * XXH_RESTRICT input, size_t len,
44704501 XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen)
44714502{
@@ -5263,7 +5294,7 @@ XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len,
52635294 * It's important for performance to pass @secretLen (when it's static)
52645295 * to the compiler, so that it can properly optimize the vectorized loop.
52655296 */
5266- XXH_FORCE_INLINE XXH128_hash_t
5297+ XXH3_WITH_SECRET_INLINE XXH128_hash_t
52675298XXH3_hashLong_128b_withSecret (const void * XXH_RESTRICT input, size_t len,
52685299 XXH64_hash_t seed64,
52695300 const void * XXH_RESTRICT secret, size_t secretLen)
0 commit comments