[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 11 17:01:54 PDT 2021
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:17145
};
- if (Var && Var->hasGlobalStorage() && !IsEmittedOnDeviceSide(Var)) {
- SemaRef.targetDiag(Loc, diag::err_ref_bad_target)
- << /*host*/ 2 << /*variable*/ 1 << Var << Target;
+ if (Var && Var->hasGlobalStorage()) {
+ if (SemaRef.LangOpts.CUDAIsDevice && !IsEmittedOnDeviceSide(Var)) {
----------------
tra wrote:
> This can be collapsed with the `if (SemaRef.LangOpts.CUDA) ` above.
This cannot be collapsed since there is else if.
================
Comment at: clang/test/CodeGenCUDA/static-device-var-rdc.cu:100-105
// HOST: __hipRegisterVar({{.*}}@_ZL1x {{.*}}@[[DEVNAMEX]]
// HOST: __hipRegisterVar({{.*}}@_ZL1y {{.*}}@[[DEVNAMEY]]
// HOST-NOT: __hipRegisterVar({{.*}}@_ZL2x2
// HOST-NOT: __hipRegisterVar({{.*}}@_ZZ6kernelPiPPKiE1w
// HOST-NOT: __hipRegisterVar({{.*}}@_ZZ6devfunPPKiE1p
+// HOST-NOT: __hipRegisterVar({{.*}}@_ZL1u
----------------
tra wrote:
> Positive checks should be `-DAG` and negative checks should be done in a separate `RUN` as we can't really guarantee the order in which registration calls are emitted.
will add separate run lines for negative tests
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102237/new/
https://reviews.llvm.org/D102237
More information about the cfe-commits
mailing list