[OpenMP] Make device functions have hidden visibility
authorJoseph Huber <jhuber6@vols.utk.edu>
Mon, 17 Oct 2022 20:53:31 +0000 (15:53 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 18 Oct 2022 13:15:39 +0000 (08:15 -0500)
commitbb3c90d3ecd142e60cf994338bdd4b59d8788cd3
tree5ecd6e5d3d7061d4944d38de40f1dab172b38338
parent6f59f302e4358b4dc869bc298c2b9c06aa716b60
[OpenMP] Make device functions have hidden visibility

In OpenMP target offloading an in other offloading languages, we
maintain a difference between device functions and kernel functions.
Kernel functions must be visible to the host and act as the entry point
to the target device. Device functions however cannot be called directly
by the host and must be called by a kernel function. Currently, we make
all definitions on the device protected by default. Because device
functions cannot be called or used by the host they should have hidden
visibility. This allows for the definitions to be better optimized via
LTO or other passes.

This patch marks every device function in the AST as having `hidden`
visibility. The kernel function is generated later at code-gen and we
set its visibility explicitly so it should not be affected. This
prevents the user from overriding the visibility, but since the user
can't do anything with these symbols anyway there is no point exporting
them right now.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D136111
clang/lib/AST/Decl.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
clang/test/OpenMP/target_attribute_convergent.cpp