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