|
| 1 | +// This test checks that lambdas assigned to variables (including inline and |
| 2 | +// templated cases) in the same namespace are uniquely mangled and callable via |
| 3 | +// template functions. It ensures that the compiler generates distinct symbols |
| 4 | +// for each lambda and resolves them correctly in function calls. |
| 5 | + |
| 6 | +// RUN: %clang_cc1 -fsycl-is-device -O0 -triple spirv64-unknown-unknown \ |
| 7 | +// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE |
| 8 | + |
| 9 | +// RUN: %clang_cc1 -fsycl-is-host -O0 -triple spirv64-unknown-unknown \ |
| 10 | +// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST |
| 11 | + |
| 12 | +// RUN: %clang_cc1 -fsycl-is-device -emit-llvm \ |
| 13 | +// RUN: -aux-triple x86_64-pc-windows-msvc -triple spir64-unknown--unknown \ |
| 14 | +// RUN: %s -o - | FileCheck %s --check-prefix=MSVC |
| 15 | + |
| 16 | +namespace QL { |
| 17 | + auto dg1 = [] { return 1; }; |
| 18 | + inline auto dg_inline1 = [] { return 1; }; |
| 19 | +} |
| 20 | + |
| 21 | +namespace QL { |
| 22 | + auto dg2 = [] { return 2; }; |
| 23 | + template<int N> |
| 24 | + auto dg_template = [] { return N; }; |
| 25 | +} |
| 26 | + |
| 27 | +using namespace QL; |
| 28 | +template<typename T> |
| 29 | +[[clang::sycl_kernel_entry_point(T)]] void f(T t) { |
| 30 | + t(); |
| 31 | +} |
| 32 | + |
| 33 | +void g() { |
| 34 | + f(dg1); |
| 35 | + f(dg2); |
| 36 | + f(dg_inline1); |
| 37 | + f(dg_template<3>); |
| 38 | +} |
| 39 | + |
| 40 | +// HOST: @_ZN2QL3dg1E = internal global %class.anon undef, align 1 |
| 41 | +// HOST: @_ZN2QL3dg2E = internal global %class.anon.0 undef, align 1 |
| 42 | +// HOST: @_ZN2QL10dg_inline1E = linkonce_odr global %class.anon.2 undef, comdat, align 1 |
| 43 | +// HOST: @_ZN2QL11dg_templateILi3EEE = linkonce_odr global %class.anon.4 undef, comdat, align 1 |
| 44 | + |
| 45 | +// DEVICE: define spir_kernel void @_ZTSN2QL3dg1MUlvE_E |
| 46 | +// DEVICE: call spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv |
| 47 | +// DEVICE: define internal spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv |
| 48 | +// DEVICE: define spir_kernel void @_ZTSN2QL3dg2MUlvE_E |
| 49 | +// DEVICE: call spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv |
| 50 | +// DEVICE: define internal spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv |
| 51 | +// DEVICE: define spir_kernel void @_ZTSN2QL10dg_inline1MUlvE_E |
| 52 | +// DEVICE: call spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv |
| 53 | +// DEVICE: define linkonce_odr spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv |
| 54 | +// DEVICE: define spir_kernel void @_ZTSN2QL11dg_templateILi3EEMUlvE_E |
| 55 | +// DEVICE: call spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv |
| 56 | +// DEVICE: define linkonce_odr spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv |
| 57 | + |
| 58 | +// HOST: define spir_func void @_Z1gv |
| 59 | +// HOST: call spir_func void @_Z1fIN2QL3dg1MUlvE_EEvT_ |
| 60 | +// HOST: call spir_func void @_Z1fIN2QL3dg2MUlvE_EEvT_ |
| 61 | +// HOST: call spir_func void @_Z1fIN2QL10dg_inline1MUlvE_EEvT_ |
| 62 | +// HOST: call spir_func void @_Z1fIN2QL11dg_templateILi3EEMUlvE_EEvT_ |
| 63 | +// HOST: define internal spir_func void @_Z1fIN2QL3dg1MUlvE_EEvT |
| 64 | +// HOST: define internal spir_func void @_Z1fIN2QL3dg2MUlvE_EEvT_ |
| 65 | +// HOST: define linkonce_odr spir_func void @_Z1fIN2QL10dg_inline1MUlvE_EEvT_ |
| 66 | +// HOST: define linkonce_odr spir_func void @_Z1fIN2QL11dg_templateILi3EEMUlvE_EEvT_ |
| 67 | + |
| 68 | +// MSVC: define dso_local spir_kernel void @_ZTSN2QL3dg1MUlvE_E |
| 69 | +// MSVC: call spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv |
| 70 | +// MSVC: define internal spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv |
| 71 | +// MSVC: define dso_local spir_kernel void @_ZTSN2QL3dg2MUlvE_E |
| 72 | +// MSVC: call spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv |
| 73 | +// MSVC: define internal spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv |
| 74 | +// MSVC: define dso_local spir_kernel void @_ZTSN2QL10dg_inline1MUlvE_E |
| 75 | +// MSVC: call spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv |
| 76 | +// MSVC: define linkonce_odr spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv |
| 77 | +// MSVC: define dso_local spir_kernel void @_ZTSN2QL11dg_templateILi3EEMUlvE_E |
| 78 | +// MSVC: call spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv |
| 79 | +// MSVC: define linkonce_odr spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv |
0 commit comments