[PATCH] D108456: [CUDA] Fix static device variables with -fgpu-rdc

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 23 10:27:09 PDT 2021


tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.

Please wait for @yaxunl . I believe he mentioned in D85223 <https://reviews.llvm.org/D85223> that he'll check whether it works on AMD's end.



================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6450
     llvm::raw_ostream &OS) const {
-  OS << ".static." << getContext().getCUIDHash();
+  OS << "__static__" << getContext().getCUIDHash();
 }
----------------
Hahnfeld wrote:
> tra wrote:
> > I would expect  NVPTXAssignValidGlobalNames.cpp to deal with this ptx quirk. 
> > I'm fine with the underscores, but it would be good we're not just covering up an issue somewhere else.
> > 
> `NVPTXAssignValidGlobalNames` checks `hasLocalLinkage`, which the `static` variables here are not (see discussion in D85223). I think the reason is that we don't want variable and function names to differ between host and device, and this might even be important here for maintaining proper connection for `cudaMemcpy`s and so on.
Right. We do need to have the same names on both sides.

I wish there was a way to avoid breaking demangling, but looks like we don't have any good options here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108456



More information about the cfe-commits mailing list