[all-commits] [llvm/llvm-project] d41445: [CUDA][HIP] Fix hostness check with -fopenmp

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Thu Mar 24 12:20:35 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d41445113bccaa037e5876659b4fd98d96af03e4
      https://github.com/llvm/llvm-project/commit/d41445113bccaa037e5876659b4fd98d96af03e4
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2022-03-24 (Thu, 24 Mar 2022)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaCUDA.cpp
    M clang/lib/Sema/SemaOverload.cpp
    A clang/test/CodeGenCUDA/openmp-parallel.cu
    A clang/test/SemaCUDA/openmp-parallel.cu

  Log Message:
  -----------
  [CUDA][HIP] Fix hostness check with -fopenmp

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.

Reviewed by: Artem Belevich, Richard Smith

Differential Revision: https://reviews.llvm.org/D121765




More information about the All-commits mailing list