Skip to content

Commit

Permalink
Fix spurious unused function warning when compiling crc32 with clang …
Browse files Browse the repository at this point in the history
…and ifunc support

Clang incorrectly warns functions only used through ifuncs are unused, llvm/llvm-project#63957.
  • Loading branch information
Zentrik authored Mar 29, 2024
1 parent d10a0fb commit 592fb80
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/crc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ JL_DLLEXPORT uint32_t jl_crc32c(uint32_t crc, const char *buf, size_t len)
return crc32c_sse42(crc, buf, len);
}
# else
#ifdef JL_CRC32C_USE_IFUNC && _COMPILER_CLANG_
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
static crc32c_func_t crc32c_dispatch(void)
{
// When used in ifunc, we cannot call external functions (i.e. jl_cpuid)
Expand All @@ -199,6 +203,9 @@ static crc32c_func_t crc32c_dispatch(void)
return crc32c_sse42;
return jl_crc32c_sw;
}
#if JL_CRC32C_USE_IFUNC && _COMPILER_CLANG_
#pragma clang diagnostic pop
#endif
// For ifdef detection below
# define crc32c_dispatch crc32c_dispatch
# define crc32c_dispatch_ifunc "crc32c_dispatch"
Expand Down

0 comments on commit 592fb80

Please sign in to comment.