Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5492,12 +5492,12 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,

TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
const TargetInfo &TI = Context.getTargetInfo();
auto *Aux = Context.getAuxTargetInfo();
// CUDA functions may have host and/or device attributes which indicate
// their targeted execution environment, therefore the calling convention
// of functions in CUDA should be checked against the target deduced based
// on their host/device attributes.
if (LangOpts.CUDA) {
auto *Aux = Context.getAuxTargetInfo();
assert(FD || CFT != CUDAFunctionTarget::InvalidTarget);
auto CudaTarget = FD ? CUDA().IdentifyTarget(FD) : CFT;
bool CheckHost = false, CheckDevice = false;
Expand All @@ -5522,6 +5522,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
A = HostTI->checkCallingConvention(CC);
if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
A = DeviceTI->checkCallingConvention(CC);
} else if (LangOpts.SYCLIsDevice && TI.getTriple().isAMDGPU() &&
CC == CC_X86VectorCall) {
A = TI.checkCallingConvention(CC);
if (Aux && A != TargetInfo::CCCR_OK)
A = Aux->checkCallingConvention(CC);
} else {
A = TI.checkCallingConvention(CC);
}
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaSYCL/Inputs/vectorcall.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

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)>;
}
5 changes: 5 additions & 0 deletions clang/test/SemaSYCL/sycl-cconv-win.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple amdgcn-amd-hsa -aux-triple x86_64-pc-windows-msvc -fsyntax-only -verify %s

// expected-no-diagnostics

#include <vectorcall.hpp>
Loading