[OpenMP][2/2] Make device functions have hidden visibility
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 28 Dec 2022 19:19:27 +0000 (11:19 -0800)
committerJohannes Doerfert <johannes@jdoerfert.de>
Tue, 3 Jan 2023 20:18:30 +0000 (12:18 -0800)
commit9ab0d4d66fa14a9c57864fea72590886ace6d9ee
treeb71630a6d85f1f955874ffa92126eeab14c24182
parent0d6b26b4d3e3991da16f5b7f53e397b0051e8598
[OpenMP][2/2]  Make device functions have hidden visibility

Similar to https://reviews.llvm.org/D136111, this time for class
methods.

D136111 summary:

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 class methods 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.
clang/lib/AST/Decl.cpp
clang/test/OpenMP/target_visibility.cpp [new file with mode: 0644]