Turns off clang optimizations on a couple of onion VFD functions (#1976)

Ancient clang (7.7.3 on OS X) emits problematic code with -O2 or -O3
This commit is contained in:
Dana Robinson 2022-08-08 12:04:01 -07:00 committed by GitHub
parent 57926d549e
commit 5d63aca604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -154,7 +154,7 @@ done:
* Failure: 0 * Failure: 0
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
*/ */
size_t size_t H5_ATTR_NO_OPTIMIZE
H5FD__onion_history_decode(unsigned char *buf, H5FD_onion_history_t *history) H5FD__onion_history_decode(unsigned char *buf, H5FD_onion_history_t *history)
{ {
uint32_t ui32 = 0; uint32_t ui32 = 0;

View File

@ -583,7 +583,7 @@ H5FD__onion_revision_index_find(const H5FD_onion_revision_index_t *rix, uint64_t
* Failure: 0 * Failure: 0
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
*/ */
size_t size_t H5_ATTR_NO_OPTIMIZE
H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_record_t *record) H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_record_t *record)
{ {
uint32_t ui32 = 0; uint32_t ui32 = 0;

View File

@ -289,6 +289,18 @@
# define H5_ATTR_MALLOC /*void*/ # define H5_ATTR_MALLOC /*void*/
# endif # endif
/* Turns off optimizations for a function. Goes after the return type.
* Not generally needed in the library, but ancient versions of clang
* (7.3.3, possibly others) have trouble with some of the onion VFD decode
* functions and need the optimizer turned off. This macro can go away when
* we figure out what's going on and can engineer another solution.
*/
# if defined(__clang__)
# define H5_ATTR_NO_OPTIMIZE __attribute__((optnone))
# else
# define H5_ATTR_NO_OPTIMIZE /*void*/
# endif
#else #else
# define H5_ATTR_FORMAT(X, Y, Z) /*void*/ # define H5_ATTR_FORMAT(X, Y, Z) /*void*/
# define H5_ATTR_UNUSED /*void*/ # define H5_ATTR_UNUSED /*void*/
@ -302,6 +314,7 @@
# define H5_ATTR_PURE /*void*/ # define H5_ATTR_PURE /*void*/
# define H5_ATTR_FALLTHROUGH /*void*/ # define H5_ATTR_FALLTHROUGH /*void*/
# define H5_ATTR_MALLOC /*void*/ # define H5_ATTR_MALLOC /*void*/
# define H5_ATTR_NO_OPTIMIZE /*void*/
#endif #endif
/* clang-format on */ /* clang-format on */