0006-xxhash-h-Fix-GCC-12-Og.patch 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From adcb38b1ffa8e401293e5028ee5af586fd304e00 Mon Sep 17 00:00:00 2001
  2. From: Mingli Yu <mingli.yu@windriver.com>
  3. Date: Wed, 12 Apr 2023 13:33:07 +0800
  4. Subject: [PATCH] xxhash.h: Fix GCC 12 -Og
  5. Change whether to inline XXH3_hashLong_withSecret to a config option
  6. Ref: https://github.com/Cyan4973/xxHash/commit/ace22bddc7a366a5dd8a71e8b8247694530684ec
  7. Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
  8. Closes GH-11062.
  9. Upstream: https://github.com/php/php-src/commit/adcb38b1ffa8e401293e5028ee5af586fd304e00
  10. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  11. ---
  12. ext/hash/xxhash/xxhash.h | 35 +++++++++++++++++++++++++++++++++--
  13. 1 file changed, 33 insertions(+), 2 deletions(-)
  14. diff --git a/ext/hash/xxhash/xxhash.h b/ext/hash/xxhash/xxhash.h
  15. index b5bd286496c7..8e816c0584eb 100644
  16. --- a/ext/hash/xxhash/xxhash.h
  17. +++ b/ext/hash/xxhash/xxhash.h
  18. @@ -1375,6 +1375,23 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
  19. */
  20. # define XXH_NO_INLINE_HINTS 0
  21. +/*!
  22. + * @def XXH3_INLINE_SECRET
  23. + * @brief Determines whether to inline the XXH3 withSecret code.
  24. + *
  25. + * When the secret size is known, the compiler can improve the performance
  26. + * of XXH3_64bits_withSecret() and XXH3_128bits_withSecret().
  27. + *
  28. + * However, if the secret size is not known, it doesn't have any benefit. This
  29. + * happens when xxHash is compiled into a global symbol. Therefore, if
  30. + * @ref XXH_INLINE_ALL is *not* defined, this will be defined to 0.
  31. + *
  32. + * Additionally, this defaults to 0 on GCC 12+, which has an issue with function pointers
  33. + * that are *sometimes* force inline on -Og, and it is impossible to automatically
  34. + * detect this optimization level.
  35. + */
  36. +# define XXH3_INLINE_SECRET 0
  37. +
  38. /*!
  39. * @def XXH32_ENDJMP
  40. * @brief Whether to use a jump for `XXH32_finalize`.
  41. @@ -1439,6 +1456,15 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
  42. # endif
  43. #endif
  44. +#ifndef XXH3_INLINE_SECRET
  45. +# if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) \
  46. + || !defined(XXH_INLINE_ALL)
  47. +# define XXH3_INLINE_SECRET 0
  48. +# else
  49. +# define XXH3_INLINE_SECRET 1
  50. +# endif
  51. +#endif
  52. +
  53. #ifndef XXH32_ENDJMP
  54. /* generally preferable for performance */
  55. # define XXH32_ENDJMP 0
  56. @@ -1515,6 +1541,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
  57. # define XXH_NO_INLINE static
  58. #endif
  59. +#if XXH3_INLINE_SECRET
  60. +# define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE
  61. +#else
  62. +# define XXH3_WITH_SECRET_INLINE XXH_NO_INLINE
  63. +#endif
  64. /* *************************************
  65. @@ -4465,7 +4496,7 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len,
  66. * so that the compiler can properly optimize the vectorized loop.
  67. * This makes a big performance difference for "medium" keys (<1 KB) when using AVX instruction set.
  68. */
  69. -XXH_FORCE_INLINE XXH64_hash_t
  70. +XXH3_WITH_SECRET_INLINE XXH64_hash_t
  71. XXH3_hashLong_64b_withSecret(const void* XXH_RESTRICT input, size_t len,
  72. XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen)
  73. {
  74. @@ -5263,7 +5294,7 @@ XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len,
  75. * It's important for performance to pass @secretLen (when it's static)
  76. * to the compiler, so that it can properly optimize the vectorized loop.
  77. */
  78. -XXH_FORCE_INLINE XXH128_hash_t
  79. +XXH3_WITH_SECRET_INLINE XXH128_hash_t
  80. XXH3_hashLong_128b_withSecret(const void* XXH_RESTRICT input, size_t len,
  81. XXH64_hash_t seed64,
  82. const void* XXH_RESTRICT secret, size_t secretLen)