-
Notifications
You must be signed in to change notification settings - Fork 808
[SYCL] Fix Lambda Mangling in Namespace-Scope Variable Initializers. #20176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This test checks that lambdas assigned to variables (including inline and | ||
// templated cases) in the same namespace are uniquely mangled and callable via | ||
// template functions. It ensures that the compiler generates distinct symbols | ||
// for each lambda and resolves them correctly in function calls. | ||
|
||
// RUN: %clang_cc1 -O0 -triple x86_64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s | ||
|
||
// RUN: %clang_cc1 -O0 -triple x86_64-pc-windows-msvc \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=MSVC | ||
|
||
namespace QL { | ||
auto dg1 = [] { return 1; }; | ||
inline auto dg_inline1 = [] { return 1; }; | ||
} | ||
|
||
namespace QL { | ||
auto dg2 = [] { return 2; }; | ||
template<int N> | ||
auto dg_template = [] { return N; }; | ||
} | ||
|
||
using namespace QL; | ||
template<typename T> | ||
void f(T t) { | ||
t(); | ||
} | ||
|
||
void g() { | ||
f(dg1); | ||
f(dg2); | ||
f(dg_inline1); | ||
f(dg_template<3>); | ||
} | ||
|
||
// CHECK: @_ZN2QL3dg1E = internal global %class.anon undef, align 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I understanding correctly that the variable names are now included in the mangling while it was not previously? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issues occur when using the |
||
// CHECK: @_ZN2QL3dg2E = internal global %class.anon.0 undef, align 1 | ||
// CHECK: @_ZN2QL10dg_inline1E = linkonce_odr global %class.anon.2 undef, comdat, align 1 | ||
// CHECK: @_ZN2QL11dg_templateILi3EEE = linkonce_odr global %class.anon.4 undef, comdat, align 1 | ||
|
||
// MSVC: @"?dg1@QL@@3V<lambda_0>@1@A" = internal global %class.anon undef, align 1 | ||
// MSVC: @"?dg2@QL@@3V<lambda_1>@1@A" = internal global %class.anon.0 undef, align 1 | ||
// MSVC: @"?dg_inline1@QL@@3V<lambda_1>@01@A" = linkonce_odr dso_local global %class.anon.2 undef, comdat, align 1 | ||
// MSVC: @"??$dg_template@$02@QL@@3V<lambda_1>@01@A" = linkonce_odr dso_local global %class.anon.4 undef, comdat, align 1 | ||
|
||
|
||
// CHECK: define internal void @"_Z1fIN2QL3$_0EEvT_" | ||
// CHECK: call noundef i32 @"_ZNK2QL3$_0clEv" | ||
// CHECK: define internal void @"_Z1fIN2QL3$_1EEvT_" | ||
// CHECK: define linkonce_odr void @_Z1fIN2QL10dg_inline1MUlvE_EEvT_ | ||
// CHECK: call noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// CHECK: define linkonce_odr void @_Z1fIN2QL11dg_templateILi3EEMUlvE_EEvT_ | ||
// CHECK: call noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv | ||
// CHECK: define internal noundef i32 @"_ZNK2QL3$_0clEv" | ||
// CHECK: define internal noundef i32 @"_ZNK2QL3$_1clEv" | ||
// CHECK: define linkonce_odr noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// CHECK: define linkonce_odr noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv | ||
|
||
// MSVC: define linkonce_odr dso_local void @"??$f@V<lambda_1>@dg_inline1@QL@@@@YAXV<lambda_1>@dg_inline1@QL@@@Z" | ||
// MSVC: call noundef i32 @"??R<lambda_1>@dg_inline1@QL@@QEBA?A?<auto>@@XZ" | ||
// MSVC: define linkonce_odr dso_local void @"??$f@V<lambda_1>@?$dg_template@$02@QL@@@@YAXV<lambda_1>@?$dg_template@$02@QL@@@Z" | ||
// MSVC: call noundef i32 @"??R<lambda_1>@?$dg_template@$02@QL@@QEBA?A?<auto>@@XZ" | ||
// MSVC: define internal noundef i32 @"??R<lambda_0>@QL@@QEBA?A?<auto>@@XZ" | ||
// MSVC: define internal noundef i32 @"??R<lambda_1>@QL@@QEBA?A?<auto>@@XZ" | ||
// MSVC: define linkonce_odr dso_local noundef i32 @"??R<lambda_1>@dg_inline1@QL@@QEBA?A?<auto>@@XZ" | ||
// MSVC: define linkonce_odr dso_local noundef i32 @"??R<lambda_1>@?$dg_template@$02@QL@@QEBA?A?<auto>@@XZ" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// This test checks that lambdas assigned to variables (including inline and | ||
// templated cases) in the same namespace are uniquely mangled and callable via | ||
// template functions. It ensures that the compiler generates distinct symbols | ||
// for each lambda and resolves them correctly in function calls. | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -O0 -triple spirv64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE | ||
|
||
// RUN: %clang_cc1 -fsycl-is-host -O0 -triple spirv64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm \ | ||
// RUN: -aux-triple x86_64-pc-windows-msvc -triple spir64-unknown--unknown \ | ||
// RUN: %s -o - | FileCheck %s --check-prefix=MSVC | ||
|
||
zahiraam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
namespace QL { | ||
auto dg1 = [] { return 1; }; | ||
inline auto dg_inline1 = [] { return 1; }; | ||
} | ||
|
||
namespace QL { | ||
auto dg2 = [] { return 2; }; | ||
template<int N> | ||
auto dg_template = [] { return N; }; | ||
} | ||
|
||
using namespace QL; | ||
template<typename T> | ||
[[clang::sycl_kernel_entry_point(T)]] void f(T t) { | ||
t(); | ||
} | ||
|
||
void g() { | ||
f(dg1); | ||
f(dg2); | ||
f(dg_inline1); | ||
f(dg_template<3>); | ||
} | ||
|
||
// HOST: @_ZN2QL3dg1E = internal global %class.anon undef, align 1 | ||
// HOST: @_ZN2QL3dg2E = internal global %class.anon.0 undef, align 1 | ||
// HOST: @_ZN2QL10dg_inline1E = linkonce_odr global %class.anon.2 undef, comdat, align 1 | ||
// HOST: @_ZN2QL11dg_templateILi3EEE = linkonce_odr global %class.anon.4 undef, comdat, align 1 | ||
|
||
// DEVICE: define spir_kernel void @_ZTSN2QL3dg1MUlvE_E | ||
// DEVICE: call spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv | ||
// DEVICE: define internal spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv | ||
// DEVICE: define spir_kernel void @_ZTSN2QL3dg2MUlvE_E | ||
// DEVICE: call spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv | ||
// DEVICE: define internal spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv | ||
// DEVICE: define spir_kernel void @_ZTSN2QL10dg_inline1MUlvE_E | ||
// DEVICE: call spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// DEVICE: define linkonce_odr spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// DEVICE: define spir_kernel void @_ZTSN2QL11dg_templateILi3EEMUlvE_E | ||
// DEVICE: call spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv | ||
// DEVICE: define linkonce_odr spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv | ||
|
||
// HOST: define spir_func void @_Z1gv | ||
// HOST: call spir_func void @_Z1fIN2QL3dg1MUlvE_EEvT_ | ||
// HOST: call spir_func void @_Z1fIN2QL3dg2MUlvE_EEvT_ | ||
// HOST: call spir_func void @_Z1fIN2QL10dg_inline1MUlvE_EEvT_ | ||
// HOST: call spir_func void @_Z1fIN2QL11dg_templateILi3EEMUlvE_EEvT_ | ||
// HOST: define internal spir_func void @_Z1fIN2QL3dg1MUlvE_EEvT | ||
// HOST: define internal spir_func void @_Z1fIN2QL3dg2MUlvE_EEvT_ | ||
// HOST: define linkonce_odr spir_func void @_Z1fIN2QL10dg_inline1MUlvE_EEvT_ | ||
// HOST: define linkonce_odr spir_func void @_Z1fIN2QL11dg_templateILi3EEMUlvE_EEvT_ | ||
|
||
// MSVC: define dso_local spir_kernel void @_ZTSN2QL3dg1MUlvE_E | ||
// MSVC: call spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv | ||
// MSVC: define internal spir_func noundef i32 @_ZNK2QL3dg1MUlvE_clEv | ||
// MSVC: define dso_local spir_kernel void @_ZTSN2QL3dg2MUlvE_E | ||
// MSVC: call spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv | ||
// MSVC: define internal spir_func noundef i32 @_ZNK2QL3dg2MUlvE_clEv | ||
// MSVC: define dso_local spir_kernel void @_ZTSN2QL10dg_inline1MUlvE_E | ||
// MSVC: call spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// MSVC: define linkonce_odr spir_func noundef i32 @_ZNK2QL10dg_inline1MUlvE_clEv | ||
// MSVC: define dso_local spir_kernel void @_ZTSN2QL11dg_templateILi3EEMUlvE_E | ||
// MSVC: call spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv | ||
// MSVC: define linkonce_odr spir_func noundef i32 @_ZNK2QL11dg_templateILi3EEMUlvE_clEv |
Uh oh!
There was an error while loading. Please reload this page.