[PATCH] D95560: [CUDA][HIP] Fix function scope static variable

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 27 13:58:49 PST 2021


yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Currently static variables are allowed in device, global, and host device
functions.

A static variable in device and global functions is supposed to have
implicit device attribute. Currently it does not. This causes incorrect
diagnostics about host variables accessed by device functions.

Another issue is static device variables are allowed in host functions
since host functions could pass them to kernels for useful computations.
Currently they are not emitted in device compilation, which should be
fixed.

This patch also handles static variables in host device functions
and function scope static managed variables, and externalization
of such variables for fno-gpu-rdc case.


https://reviews.llvm.org/D95560

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-func-scope-static-var.cu
  clang/test/CodeGenCUDA/func-scope-static-var.cu
  clang/test/SemaCUDA/func-scope-static-var.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95560.319658.patch
Type: text/x-patch
Size: 22646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210127/17736e10/attachment-0001.bin>


More information about the cfe-commits mailing list