[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 9 13:40:25 PST 2019


hliao created this revision.
hliao added reviewers: tra, jlebar, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hliao updated this revision to Diff 232933.
hliao added a comment.
hliao edited the summary of this revision.

refine commit message


- As global initializers are not under any function body, they needs to look into the current variable being initialized. That is not addressed in the current CUDA/HIP overloadable function resolution and ignore target checking. That may result in wrong candidate to be considered as illustrated in the newly added test case.
- In this patch, a non-local varialble stack is introduced to keep trace the current non-local variable being initialized so that initialization function could be inspected for the target preference.
- Besides newly added tests, existing tests are refined as the current implementation adds extra check on global initializers to ensure no device functions are used.  As the target match checking is enabled in this patch, such check is only necessary for CUDA device global variables. They are not allowed to be non-trivially inialized. As HIP starts to support non-trivial initialization of device initialization, such target matching check is mandatory to be enforced.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71227.232933.patch
Type: text/x-patch
Size: 19924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191209/f2c2e6cf/attachment-0001.bin>


More information about the cfe-commits mailing list