@@ -1375,6 +1375,23 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1375
1375
*/
1376
1376
# define XXH_NO_INLINE_HINTS 0
1377
1377
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
+
1378
1395
/* !
1379
1396
* @def XXH32_ENDJMP
1380
1397
* @brief Whether to use a jump for `XXH32_finalize`.
@@ -1439,6 +1456,15 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1439
1456
# endif
1440
1457
#endif
1441
1458
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
+
1442
1468
#ifndef XXH32_ENDJMP
1443
1469
/* generally preferable for performance */
1444
1470
# define XXH32_ENDJMP 0
@@ -1515,6 +1541,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
1515
1541
# define XXH_NO_INLINE static
1516
1542
#endif
1517
1543
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
1518
1549
1519
1550
1520
1551
/* *************************************
@@ -4465,7 +4496,7 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len,
4465
4496
* so that the compiler can properly optimize the vectorized loop.
4466
4497
* This makes a big performance difference for "medium" keys (<1 KB) when using AVX instruction set.
4467
4498
*/
4468
- XXH_FORCE_INLINE XXH64_hash_t
4499
+ XXH3_WITH_SECRET_INLINE XXH64_hash_t
4469
4500
XXH3_hashLong_64b_withSecret (const void * XXH_RESTRICT input, size_t len,
4470
4501
XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen)
4471
4502
{
@@ -5263,7 +5294,7 @@ XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len,
5263
5294
* It's important for performance to pass @secretLen (when it's static)
5264
5295
* to the compiler, so that it can properly optimize the vectorized loop.
5265
5296
*/
5266
- XXH_FORCE_INLINE XXH128_hash_t
5297
+ XXH3_WITH_SECRET_INLINE XXH128_hash_t
5267
5298
XXH3_hashLong_128b_withSecret (const void * XXH_RESTRICT input, size_t len,
5268
5299
XXH64_hash_t seed64,
5269
5300
const void * XXH_RESTRICT secret, size_t secretLen)
0 commit comments