[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code
Jon Chesterfield via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 14:39:16 PDT 2020
JonChesterfield added inline comments.
================
Comment at: clang/lib/AST/ASTContext.cpp:10068
+ isa<VarDecl>(D) && cast<VarDecl>(D)->isFileVarDecl() &&
+ cast<VarDecl>(D)->getStorageClass() == SC_Static) {
+ return GVA_StrongExternal;
----------------
yaxunl wrote:
> rjmccall wrote:
> > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language?
> function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it.
This doesn't sound right. An inline function can return a pointer to a function scope static variable, e.g. to implement a singleton in a header file. I think host code can then access said variable.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80858/new/
https://reviews.llvm.org/D80858
More information about the cfe-commits
mailing list