[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-22 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: > @yxsamliu What's the plan here? This issue is blocking us. If there is no > obvious fix very soon, we need to revert this. fix by https://github.com/llvm/llvm-project/pull/73140 https://github.com/llvm/llvm-project/pull/72394 ___ cf

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-21 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: > @yxsamliu What's the plan here? This issue is blocking us. If there is no > obvious fix very soon, we need to revert this. I will fix it. https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commits@lists

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-21 Thread via cfe-commits
alexfh wrote: @yxsamliu What's the plan here? This issue is blocking us. If there is no obvious fix very soon, we need to revert this. https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-21 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: Thanks for reporting. A reduced testcase is https://godbolt.org/z/MY84az9xh `template struct ptr { ~ptr() { static int x = 1;} }; template struct Abc : ptr { public: Abc(); ~Abc() {} }; template class Abc; ` clang thinks Abc::~Abc() is trivial but it is not. It cou

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-21 Thread via cfe-commits
bgra8 wrote: @yxsamliu we found another problem with the patch. https://godbolt.org/z/5M9eexKKM ``` #include template class Abc { public: Abc(); ~Abc(); private: struct Impl; std::unique_ptr impl_; }; template struct Abc::Impl { int x; }; template Abc::Abc() : impl_{std::

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-19 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: > > We've found a problem with the patch. https://godbolt.org/z/jcKo34vzG > > ``` > > template > > class C { > > explicit C() {}; > > }; > > > > template <> C::C() {}; > > ``` > > > > > > > > > > > > > > > > > > > > > > > > ``` > > :6

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-19 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: > We've found a problem with the patch. https://godbolt.org/z/jcKo34vzG > > ``` > template > class C { > explicit C() {}; > }; > > template <> C::C() {}; > ``` > > ``` > :6:21: error: __host__ function 'C' cannot overload __host__ > __device__ function 'C' > 6 | templ

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-18 Thread Artem Belevich via cfe-commits
Artem-B wrote: We've found a problem with the patch. https://godbolt.org/z/jcKo34vzG ``` template class C { explicit C() {}; }; template <> C::C() {}; ``` :6:21: error: __host__ function 'C' cannot overload __host__ __device__ function 'C' 6 | template <> C::C() {}; |

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-16 Thread Yaxun Liu via cfe-commits
https://github.com/yxsamliu closed https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Yaxun Liu via cfe-commits
https://github.com/yxsamliu updated https://github.com/llvm/llvm-project/pull/72394 >From 0efce26340ce058cd2477f5dccbb6ab35cb1c2a0 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 14 Nov 2023 22:08:45 -0500 Subject: [PATCH] [CUDA][HIP] make trivial ctor/dtor host device Make trivial

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Yaxun Liu via cfe-commits
@@ -12,7 +12,7 @@ extern "C" void host_fn() {} struct Dummy {}; struct S { - S() {} + S() { x = 1; } yxsamliu wrote: will do https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commit

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Yaxun Liu via cfe-commits
@@ -772,6 +772,26 @@ void Sema::maybeAddCUDAHostDeviceAttrs(FunctionDecl *NewD, NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context)); } +// If a trivial ctor/dtor has no host/device +// attributes, make it implicitly host device function. +void Sema::maybeAddCUDAHostDevice

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Artem Belevich via cfe-commits
@@ -772,6 +772,26 @@ void Sema::maybeAddCUDAHostDeviceAttrs(FunctionDecl *NewD, NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context)); } +// If a trivial ctor/dtor has no host/device +// attributes, make it implicitly host device function. +void Sema::maybeAddCUDAHostDevice

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Artem Belevich via cfe-commits
@@ -12,7 +12,7 @@ extern "C" void host_fn() {} struct Dummy {}; struct S { - S() {} + S() { x = 1; } Artem-B wrote: Can we make the purpose of non-trivial constructor more descriptive, here and in other places? E.g. `S() { static int nontrivial_ctor = 1; }

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Artem Belevich via cfe-commits
https://github.com/Artem-B approved this pull request. LGTM with a couple of nits. https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Artem Belevich via cfe-commits
https://github.com/Artem-B edited https://github.com/llvm/llvm-project/pull/72394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Yaxun (Sam) Liu (yxsamliu) Changes Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: https://github.com/llvm/llvm-project/issues/72261

[clang] [CUDA][HIP] make trivial ctor/dtor host device (PR #72394)

2023-11-15 Thread Yaxun Liu via cfe-commits
https://github.com/yxsamliu created https://github.com/llvm/llvm-project/pull/72394 Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: https://github.com/llvm/llvm-project/issues/72261 Fixes