Skip to content

Commit 0666559

Browse files
committed
[SYCL][clang][Sema] Fix HIP compliation with MSVC headers
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent ecf26d1 commit 0666559

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -5544,12 +5544,12 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
55445544
}
55455545

55465546
TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
5547+
auto *Aux = Context.getAuxTargetInfo();
55475548
// CUDA functions may have host and/or device attributes which indicate
55485549
// their targeted execution environment, therefore the calling convention
55495550
// of functions in CUDA should be checked against the target deduced based
55505551
// on their host/device attributes.
55515552
if (LangOpts.CUDA) {
5552-
auto *Aux = Context.getAuxTargetInfo();
55535553
assert(FD || CFT != CUDAFunctionTarget::InvalidTarget);
55545554
auto CudaTarget = FD ? CUDA().IdentifyTarget(FD) : CFT;
55555555
bool CheckHost = false, CheckDevice = false;
@@ -5574,6 +5574,12 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
55745574
A = HostTI->checkCallingConvention(CC);
55755575
if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
55765576
A = DeviceTI->checkCallingConvention(CC);
5577+
} else if (LangOpts.SYCLIsDevice && Aux->getTriple().isOSWindows() &&
5578+
TI.getTriple().isAMDGPU() &&
5579+
getSourceManager().isInSystemHeader(Attrs.getScopeLoc())) {
5580+
A = TI.checkCallingConvention(CC);
5581+
if (A != TargetInfo::CCCR_OK)
5582+
A = Aux->checkCallingConvention(CC);
55775583
} else {
55785584
A = TI.checkCallingConvention(CC);
55795585
}
+18
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+
}
+5
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>

sycl/source/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
136136
target_link_libraries(${LIB_NAME} PRIVATE ${ARG_XPTI_LIB})
137137
endif()
138138

139-
if (NOT LLVM_ENABLE_ZSTD)
139+
if (true)
140140
target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_RT_ZSTD_NOT_AVAIABLE)
141141
else()
142142
target_link_libraries(${LIB_NAME} PRIVATE ${zstd_STATIC_LIBRARY})

0 commit comments

Comments
 (0)