This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Make device functions have hidden visibility
ClosedPublic

Authored by jhuber6 on Oct 17 2022, 2:01 PM.

Details

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 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.

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 17 2022, 2:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2022, 2:01 PM
jhuber6 requested review of this revision.Oct 17 2022, 2:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2022, 2:01 PM
jhuber6 updated this revision to Diff 468328.Oct 17 2022, 2:28 PM

We can't make every function hidden for non-GPU offloading. So we only apply it to the functions inside the declare target clause there.

jdoerfert accepted this revision.Oct 17 2022, 4:08 PM

LG, should be fine.

This revision is now accepted and ready to land.Oct 17 2022, 4:08 PM
This revision was automatically updated to reflect the committed changes.