Skip to content

Commit 6ed0ba1

Browse files
committed
[clang][Sema][SYCL] Fix MSVC STL usage on AMDGPU
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 4aca20c commit 6ed0ba1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5492,12 +5492,12 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
54925492

54935493
TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
54945494
const TargetInfo &TI = Context.getTargetInfo();
5495+
auto *Aux = Context.getAuxTargetInfo();
54955496
// CUDA functions may have host and/or device attributes which indicate
54965497
// their targeted execution environment, therefore the calling convention
54975498
// of functions in CUDA should be checked against the target deduced based
54985499
// on their host/device attributes.
54995500
if (LangOpts.CUDA) {
5500-
auto *Aux = Context.getAuxTargetInfo();
55015501
assert(FD || CFT != CUDAFunctionTarget::InvalidTarget);
55025502
auto CudaTarget = FD ? CUDA().IdentifyTarget(FD) : CFT;
55035503
bool CheckHost = false, CheckDevice = false;
@@ -5522,6 +5522,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
55225522
A = HostTI->checkCallingConvention(CC);
55235523
if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
55245524
A = DeviceTI->checkCallingConvention(CC);
5525+
} else if (LangOpts.SYCLIsDevice && TI.getTriple().isAMDGPU() &&
5526+
CC == CC_X86VectorCall) {
5527+
A = TI.checkCallingConvention(CC);
5528+
if (Aux && A != TargetInfo::CCCR_OK)
5529+
A = Aux->checkCallingConvention(CC);
55255530
} else {
55265531
A = TI.checkCallingConvention(CC);
55275532
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
template <typename F> struct A{};
3+
4+
template <typename Ret, typename C, typename... Args> struct A<Ret ( C::*)(Args...) noexcept> { static constexpr int value = 0; };
5+
template <typename Ret, typename C, typename... Args> struct A<Ret (__vectorcall C::*)(Args...) noexcept> { static constexpr int value = 1; };
6+
7+
template <typename F> constexpr int A_v = A<F>::value;
8+
9+
struct B
10+
{
11+
void f() noexcept {}
12+
void __vectorcall g() noexcept {}
13+
};
14+
15+
int main()
16+
{
17+
return A_v<decltype(&B::f)> + A_v<decltype(&B::g)>;
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple amdgcn-amd-hsa -aux-triple x86_64-pc-windows-msvc -fsyntax-only -verify %s
2+
3+
// expected-no-diagnostics
4+
5+
#include <vectorcall.hpp>

0 commit comments

Comments
 (0)