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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to