[PATCH] D95901: [CUDA][HIP] Fix device variable linkage
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 09:58:45 PST 2021
tra added a comment.
> For -fgpu-rdc, shadow variables should not be internalized, otherwise they cannot be accessed by other TUs.
> This is necessary because the shadow variable of external device variables are always emitted as undefined symbols, which need to resolve to a global symbols.
Does it mean that we always internalize shadows *now*, before this patch? That would indeed be wrong. Shadow's visibility should be the same as that of a variable without a `__device__`.
Next question is whether the behavior should be different for `-fgpu-rdc` vs non-RDC. I think shadows should behave the same regardless of RDC mode and make things work closer to what users would expect from regular C++ code. We already have mechanisms to uniquify the variables, if necessary, so we don't need to use visibility to avoid cross-TU linking conflicts.
================
Comment at: clang/lib/AST/ASTContext.cpp:11437-11443
+ return ((!getLangOpts().GPURelocatableDeviceCode &&
+ ((D->hasAttr<CUDADeviceAttr>() &&
+ !D->getAttr<CUDADeviceAttr>()->isImplicit()) ||
+ (D->hasAttr<CUDAConstantAttr>() &&
+ !D->getAttr<CUDAConstantAttr>()->isImplicit()))) ||
D->hasAttr<HIPManagedAttr>()) &&
isa<VarDecl>(D) && cast<VarDecl>(D)->getStorageClass() == SC_Static;
----------------
I can't parse it. :-( Perhaps we can split it.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95901/new/
https://reviews.llvm.org/D95901
More information about the cfe-commits
mailing list