[PATCH] D121765: [CUDA][HIP] Fix hostness check with -fopenmp

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 19:56:22 PDT 2022


yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: carlosgalvezp, guansong.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

CUDA/HIP determines whether a function can be called based on
the device/host attributes of callee and caller. Clang assumes the
caller is CurContext. This is correct in most cases, however, it is
not correct in OpenMP parallel region when CUDA/HIP program
is compiled with -fopenmp. This causes incorrect overloading
resolution and missed diagnostics.

To get the correct caller, clang needs to chase the parent chain
of DeclContext starting from CurContext until a function decl
or a lambda decl is reached. Sema API is adapted to achieve that
and used to determine the caller in hostness check.


https://reviews.llvm.org/D121765

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCUDA/openmp-parallel.cu
  clang/test/SemaCUDA/openmp-parallel.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121765.415673.patch
Type: text/x-patch
Size: 11772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220316/d465bd29/attachment-0001.bin>


More information about the cfe-commits mailing list