SWDEV-572439: make assert_fail constexpr in the hip headers (#2392)

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
This commit is contained in:
Shadi Dashmiz
2026-01-30 15:41:17 -05:00
committed by GitHub
szülő e1844f6a59
commit f1e5612e26
3 fájl változott, egészen pontosan 71 új sor hozzáadva és 3 régi sor törölve
@@ -24,6 +24,14 @@ THE SOFTWARE.
#if defined(__clang__) && defined(__HIP__)
// Use constexpr only in C++14 and later where constexpr void is allowed.
// In C++11, void is not a literal type and cannot be used as constexpr return type.
#if defined(__cplusplus) && __cplusplus >= 201402L
#define __HIP_CONSTEXPR_VOID constexpr
#else
#define __HIP_CONSTEXPR_VOID
#endif
// abort
extern "C" __device__ inline __attribute__((weak)) void abort() { __builtin_trap(); }
@@ -33,13 +41,13 @@ extern "C" __device__ inline __attribute__((weak)) void abort() { __builtin_trap
// allows the function to exist as a global although its definition is
// included in every compilation unit.
#if defined(_WIN32) || defined(_WIN64)
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) void _wassert(
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) __HIP_CONSTEXPR_VOID void _wassert(
const wchar_t* _msg, const wchar_t* _file, unsigned _line) {
// FIXME: Need `wchar_t` support to generate assertion message.
__builtin_trap();
}
#else /* defined(_WIN32) || defined(_WIN64) */
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) void __assert_fail(
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) __HIP_CONSTEXPR_VOID void __assert_fail(
const char* assertion, const char* file, unsigned int line, const char* function) {
const char fmt[] = "%s:%u: %s: Device-side assertion `%s' failed.\n";
@@ -77,7 +85,7 @@ extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) void __ass
__builtin_trap();
}
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) void __assertfail() {
extern "C" __device__ __attribute__((noinline)) __attribute__((weak)) __HIP_CONSTEXPR_VOID void __assertfail() {
// ignore all the args for now.
__builtin_trap();
}