[PATCH] D67509: [CUDA][HIP] Fix hostness of defaulted constructor

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 22 18:14:55 PDT 2019


yaxunl added a comment.

In D67509#1677722 <https://reviews.llvm.org/D67509#1677722>, @yaxunl wrote:

> In D67509#1677586 <https://reviews.llvm.org/D67509#1677586>, @yaxunl wrote:
>
> > In D67509#1677528 <https://reviews.llvm.org/D67509#1677528>, @tra wrote:
> >
> > > Looks like CUDA test-suite is triggering the assertion added by this patch:
> > >
> > > http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37301/steps/ninja%20build%20simple%20CUDA%20tests/logs/stdio
> >
> >
> > I am taking a look.
>
>
> I can reproduce similar asserts locally. It seems the assertion I added `assert(!(HasD || HasH) || (NeedsD == HasD && NeedsH == HasH));` is not always true. Since we do not have this assert before, I removed it. I will study what causes it to assert and post it later.


A reduced test case is

  struct A {
    A();
  };
  
  template <class T>
  struct B
  {
    T a;
    constexpr B() = default;
  };
  
  B<A> x;

`B<A>::B()` got implicit `__host__ __device__`  attrs due to constexpr before entering Sema::inferCUDATargetForImplicitSpecialMember.
In Sema::inferCUDATargetForImplicitSpecialMember, the inferred hostness of `B<A>::B()` is host since `A::A()` is host. This causes discrepancy between the inferred hostness and the existing hostness.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67509/new/

https://reviews.llvm.org/D67509





More information about the cfe-commits mailing list