
Summary: There's some logic in the AMDGPU target that manually resets the requested visibility of certain variables. This was triggering when we set a constant variable in OpenMP. However, we shouldn't do this for OpenMP when the variable has the `nohost` type. That implies that the variable is not visible to the host and therefore does not need to be visible, so we should respect the original value of it.
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
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-target-device -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-target-device -o - | FileCheck %s
|
|
// expected-no-diagnostics
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
struct A {
|
|
void foo() {}
|
|
static void sfoo() {}
|
|
};
|
|
|
|
#pragma omp end declare target
|
|
|
|
struct B {
|
|
void bar();
|
|
static void sbar();
|
|
};
|
|
|
|
void B::bar() { A a; a.foo(); }
|
|
void B::sbar() { A::sfoo(); }
|
|
#pragma omp declare target to(B::bar, B::sbar)
|
|
|
|
[[gnu::visibility("hidden")]] extern const int x = 0;
|
|
#pragma omp declare target to(x) device_type(nohost)
|
|
|
|
[[gnu::visibility("hidden")]] int y = 0;
|
|
#pragma omp declare target to(y)
|
|
|
|
// CHECK-DAG: @x = hidden{{.*}} constant i32 0
|
|
// CHECK-DAG: @y = protected{{.*}} i32 0
|
|
// CHECK-DAG: define hidden void @_ZN1B4sbarEv()
|
|
// CHECK-DAG: define linkonce_odr hidden void @_ZN1A4sfooEv()
|
|
// CHECK-DAG: define hidden void @_ZN1B3barEv(
|
|
// CHECK-DAG: define linkonce_odr hidden void @_ZN1A3fooEv(
|