1 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
2 // RUN: -fgpu-rdc -std=c++11 -emit-llvm -o - -target-cpu gfx906 | FileCheck %s
4 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
5 // RUN: -fgpu-rdc -std=c++11 -emit-llvm -o - -target-cpu gfx906 \
6 // RUN: | FileCheck -check-prefix=NEG %s
8 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
9 // RUN: -std=c++11 -emit-llvm -o - -target-cpu gfx906 \
10 // RUN: | FileCheck -check-prefixes=NEG,NORDC %s
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -x hip %s \
13 // RUN: -fgpu-rdc -std=c++11 -emit-llvm -o - \
14 // RUN: | FileCheck -check-prefix=HOST-NEG %s
17 #include "Inputs/cuda.h"
19 // CHECK-LABEL: @__clang_gpu_used_external = internal {{.*}}global
20 // CHECK-DAG: @_Z7kernel1v
21 // CHECK-DAG: @_Z7kernel4v
23 // CHECK-LABEL: @llvm.compiler.used = {{.*}} @__clang_gpu_used_external
25 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel2v
26 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel3v
27 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @var2
28 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @var3
29 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @ext_shvar
30 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @shvar
31 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel1v
32 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel4v
33 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @var1
34 // HOST-NEG-NOT: call void @__hipRegisterVar({{.*}}, ptr @ext_shvar
35 // HOST-NEG-NOT: call void @__hipRegisterVar({{.*}}, ptr @shvar
36 __global__ void kernel1();
38 // kernel2 is not marked as used since it is a definition.
39 __global__ void kernel2() {}
41 // kernel3 is not marked as used since it is not called by host function.
42 __global__ void kernel3();
44 // kernel4 is marked as used even though it is not called.
45 __global__ void kernel4();
47 extern __device__ int var1;
51 extern __device__ int var3;
57 void *p = (void*)kernel4;
61 __global__ void test_lambda_using_extern_shared() {
62 extern __shared__ int ext_shvar[];
63 __shared__ int shvar[10];