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 = {{.*}} @_Z7kernel5v
28 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @var2
29 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @var3
30 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @ext_shvar
31 // NEG-NOT: @__clang_gpu_used_external = {{.*}} @shvar
32 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel1v
33 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel4v
34 // NORDC-NOT: @__clang_gpu_used_external = {{.*}} @var1
35 // HOST-NEG-NOT: call void @__hipRegisterVar({{.*}}, ptr @ext_shvar
36 // HOST-NEG-NOT: call void @__hipRegisterVar({{.*}}, ptr @shvar
37 __global__ void kernel1();
39 // kernel2 is not marked as used since it is a definition.
40 __global__ void kernel2() {}
42 // kernel3 is not marked as used since it is not called by host function.
43 __global__ void kernel3();
45 // kernel4 is marked as used even though it is not called.
46 __global__ void kernel4();
48 // kernel5 is not marked as used since it is called by host function
49 // with weak_odr linkage, which may be dropped by linker.
50 __global__ void kernel5();
52 extern __device__ int var1;
56 extern __device__ int var3;
62 void *p = (void*)kernel4;
66 __global__ void test_lambda_using_extern_shared() {
67 extern __shared__ int ext_shvar[];
68 __shared__ int shvar[10];
77 void template_caller() {
82 template void template_caller<int>();