Skip to content

[clang][SYCL] Print canonical types in free function shim functions #16119

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

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6510,6 +6510,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
std::string ParmList;
bool FirstParam = true;
Policy.SuppressDefaultTemplateArgs = false;
Policy.PrintCanonicalTypes = true;
for (ParmVarDecl *Param : K.SyclKernel->parameters()) {
if (FirstParam)
FirstParam = false;
Expand All @@ -6518,6 +6519,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
ParmList += Param->getType().getCanonicalType().getAsString(Policy);
}
FunctionTemplateDecl *FTD = K.SyclKernel->getPrimaryTemplate();
Policy.PrintCanonicalTypes = false;
Policy.SuppressDefinition = true;
Policy.PolishForDeclaration = true;
Policy.FullyQualifiedName = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ templated3(Arg<T, notatuple, a, ns1::hasDefaultArg<>, int, int>, T end) {

template void templated3(Arg<int, notatuple, 3, ns1::hasDefaultArg<>, int, int>, int);


namespace sycl {
template <typename T> struct X {};
template <> struct X<int> {};
namespace detail {
struct Y {};
} // namespace detail
template <> struct X<detail::Y> {};
} // namespace sycl
using namespace sycl;
template <typename T, typename = X<detail::Y>> struct Arg1 { T val; };

[[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel",
2)]] void
foo(Arg1<int> arg) {
arg.val = 42;
}

// CHECK: Forward declarations of kernel and its argument types:
// CHECK-NEXT: namespace ns {
// CHECK-NEXT: struct notatuple;
Expand Down Expand Up @@ -98,3 +116,17 @@ template void templated3(Arg<int, notatuple, 3, ns1::hasDefaultArg<>, int, int>,
// CHECK-NEXT: static constexpr auto __sycl_shim5() {
// CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 3, class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, int>, int))templated3<int, 3>;
// CHECK-NEXT: }

// CHECK Forward declarations of kernel and its argument types:
// CHECK: namespace sycl { namespace detail {
// CHECK-NEXT: struct Y;
// CHECK-NEXT: }}
// CHECK-NEXT: namespace sycl {
// CHECK-NEXT: template <typename T> struct X;
// CHECK-NEXT: }
// CHECK-NEXT: template <typename T, typename> struct Arg1;

// CHECK: void foo(Arg1<int, sycl::X<sycl::detail::Y> > arg);
// CHECK-NEXT: static constexpr auto __sycl_shim6() {
// CHECK-NEXT: return (void (*)(struct Arg1<int, struct sycl::X<struct sycl::detail::Y> >))foo;
// CHECK-NEXT: }
Loading