llvm-capstone/clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp
Alex Richardson 0745b0c035 Fix incorrect cast in VisitSYCLUniqueStableNameExpr
Clang language-level address spaces and LLVM pointer address spaces are
not the same thing (even though they will both have a numeric value of
zero in many cases). LangAS is a enum class to avoid implicit conversions,
but eba69b59d1a30dead07da2c279c8ecfd2b62ba9f avoided the compiler error by
adding a `static_cast<>`. While touching this code, simplify it by using
CreatePointerBitCastOrAddrSpaceCast() which is already a no-op if the types
match.

This changes the code generation for spir64 to place the globals in
the sycl_global addreds space, which maps to `addrspace(1)`.

Reviewed By: bader

Differential Revision: https://reviews.llvm.org/D138284
2022-11-19 11:43:17 +00:00

45 lines
1.6 KiB
C++

// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) '
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE='
template<typename KN, typename Func>
__attribute__((sycl_kernel)) void kernel(Func F){
F();
}
template<typename KN, typename Func>
__attribute__((sycl_kernel)) void kernel2(Func F){
F(1);
}
template<typename KN, typename Func>
__attribute__((sycl_kernel)) void kernel3(Func F){
F(1.1);
}
int main() {
int i;
double d;
float f;
auto lambda1 = [](){};
auto lambda2 = [](int){};
auto lambda3 = [](double){};
kernel<class K1>(lambda1);
kernel2<class K2>(lambda2);
kernel3<class K3>(lambda3);
// Ensure the kernels are named the same between the device and host
// invocations.
(void)__builtin_sycl_unique_stable_name(decltype(lambda1));
(void)__builtin_sycl_unique_stable_name(decltype(lambda2));
(void)__builtin_sycl_unique_stable_name(decltype(lambda3));
// Make sure the following 3 are the same between the host and device compile.
// Note that these are NOT the same value as eachother, they differ by the
// signature.
// CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUlvE_\00"
// CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUliE_\00"
// CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUldE_\00"
}