150
|
1 // Make sure that __global__ functions are emitted along with correct
|
|
2 // annotations and are added to @llvm.used to prevent their elimination.
|
|
3 // REQUIRES: nvptx-registered-target
|
|
4 //
|
252
|
5 // RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
|
150
|
6
|
|
7 #include "Inputs/cuda.h"
|
|
8
|
221
|
9 // CHECK-LABEL: define{{.*}} void @device_function
|
150
|
10 extern "C"
|
|
11 __device__ void device_function() {}
|
|
12
|
221
|
13 // CHECK-LABEL: define{{.*}} void @global_function
|
150
|
14 extern "C"
|
|
15 __global__ void global_function() {
|
|
16 // CHECK: call void @device_function
|
|
17 device_function();
|
|
18 }
|
|
19
|
|
20 // Make sure host-instantiated kernels are preserved on device side.
|
|
21 template <typename T> __global__ void templated_kernel(T param) {}
|
221
|
22 // CHECK-DAG: define{{.*}} void @_Z16templated_kernelIiEvT_(
|
150
|
23
|
|
24 namespace {
|
|
25 __global__ void anonymous_ns_kernel() {}
|
221
|
26 // CHECK-DAG: define{{.*}} void @_ZN12_GLOBAL__N_119anonymous_ns_kernelEv(
|
150
|
27 }
|
|
28
|
|
29 void host_function() {
|
|
30 templated_kernel<<<0, 0>>>(0);
|
|
31 anonymous_ns_kernel<<<0,0>>>();
|
|
32 }
|
|
33
|
252
|
34 // CHECK: !{{[0-9]+}} = !{ptr @global_function, !"kernel", i32 1}
|
|
35 // CHECK: !{{[0-9]+}} = !{ptr @_Z16templated_kernelIiEvT_, !"kernel", i32 1}
|