[OpenMP] Make Ctor / Dtor functions have external visibility
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 25 Mar 2022 20:36:57 +0000 (16:36 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Sat, 26 Mar 2022 02:44:17 +0000 (22:44 -0400)
commit3c6d32ec6cdb426d531e0a3b3aa4449ff6e4d75c
treedda28d1bec25d3f4bad54e39081c092b5fbc1579
parente13faa40cf0a727a76e395ab4123b9d2ca527b49
[OpenMP] Make Ctor / Dtor functions have external visibility

The default construction of constructor functions by LLVM tends to make
them have internal linkage. When we call a ctor / dtor function in the
target region we are actually creating a kernel that is called at
registration. Because the ctor is a kernel we need to make sure it's
externally visible so we can actually call it. This prevented AMDGPU
from correctly using constructors while NVPTX could use them simply
because it ignored internal visibility.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D122504
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/OpenMP/amdgcn_target_global_constructor.cpp
clang/test/OpenMP/declare_target_codegen.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp