[PATCH] D102237: [CUDA][HIP] Fix non-ODR-use of static device variable

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 18 14:33:18 PDT 2021


yaxunl added a comment.

In D102237#2767052 <https://reviews.llvm.org/D102237#2767052>, @tra wrote:

> Sam, this patch has apparently triggered some unwanted side effects. I'm still reducing the failures to something that could be used for debugging, but the rough symptoms are:
>
> We now end up emitting the code for the host-only static member functions of instantiated class templates during device-side compilation.
> Clang now complains about not allowed nontrivial static initializers for some variables in class templates.



In D102237#2767052 <https://reviews.llvm.org/D102237#2767052>, @tra wrote:

> Sam, this patch has apparently triggered some unwanted side effects. I'm still reducing the failures to something that could be used for debugging, but the rough symptoms are:
>
> We now end up emitting the code for the host-only static member functions of instantiated class templates during device-side compilation.
> Clang now complains about not allowed nontrivial static initializers for some variables in class templates.

We limit the variables to device or constant variables, e.g. https://godbolt.org/z/seh1n7KnY

xxx is emitted because it is implicitly constant, but yyy is not emitted.

It would be interesting to know what kind of variables are emitted.

Would you like the change reverted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102237



More information about the cfe-commits mailing list