mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 02:06:06 +00:00

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
14 lines
714 B
C++
14 lines
714 B
C++
// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fvisibility=protected -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fvisibility=protected -o - | FileCheck %s
|
|
// expected-no-diagnostics
|
|
|
|
#pragma omp declare target
|
|
|
|
void foo() {}
|
|
|
|
#pragma omp end declare target
|
|
|
|
// CHECK: Function Attrs: {{.*}}convergent{{.*}}
|
|
// CHECK: define hidden void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
|
|
// CHECK: attributes [[ATTRIBUTE_NUMBER]] = { {{.*}}convergent{{.*}} }
|