Nick Sarnie 257b727584
[clang][Sema][SYCL] Fix MSVC STL usage on AMDGPU (#135979)
The MSVC STL includes specializations of `_Is_memfunptr` for every
function pointer type, including every calling convention.

The problem is the AMDGPU target doesn't support the x86 `vectorcall`
calling convention so clang sets it to the default CC. This ends up
clashing with the already-existing overload for the default CC, so we
get a duplicate definition error when including `type_traits` (which we
heavily use in the SYCL STL) and compiling for AMDGPU on Windows.

This doesn't happen for pure AMDGPU non-SYCL because it doesn't include
the C++ STL, and it doesn't happen for CUDA/HIP because a similar
workaround was done
[here](fa49c3a888).

I am not an expert in Sema, so I did a kinda of hardcoded fix, please
let me know if there is a better way to fix this.

As far as I can tell we can't do exactly the same fix that was done for
CUDA because we can't differentiate between device and host code so
easily.

---------

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-04-18 15:28:46 +00:00

19 lines
528 B
C++

template <typename F> struct A{};
template <typename Ret, typename C, typename... Args> struct A<Ret ( C::*)(Args...) noexcept> { static constexpr int value = 0; };
template <typename Ret, typename C, typename... Args> struct A<Ret (__vectorcall C::*)(Args...) noexcept> { static constexpr int value = 1; };
template <typename F> constexpr int A_v = A<F>::value;
struct B
{
void f() noexcept {}
void __vectorcall g() noexcept {}
};
int main()
{
return A_v<decltype(&B::f)> + A_v<decltype(&B::g)>;
}