2015-09-23 01:22:51 +08:00
|
|
|
// Make sure that __global__ functions are emitted along with correct
|
|
|
|
// annotations and are added to @llvm.used to prevent their elimination.
|
|
|
|
// REQUIRES: nvptx-registered-target
|
|
|
|
//
|
2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
|
2011-10-07 00:49:54 +08:00
|
|
|
|
2014-04-29 06:21:28 +08:00
|
|
|
#include "Inputs/cuda.h"
|
2011-10-07 00:49:54 +08:00
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @device_function
|
2013-03-30 22:38:24 +08:00
|
|
|
extern "C"
|
2011-10-07 00:49:54 +08:00
|
|
|
__device__ void device_function() {}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @global_function
|
2013-03-30 22:38:24 +08:00
|
|
|
extern "C"
|
2011-10-07 00:49:54 +08:00
|
|
|
__global__ void global_function() {
|
2013-03-30 22:38:24 +08:00
|
|
|
// CHECK: call void @device_function
|
2011-10-07 00:49:54 +08:00
|
|
|
device_function();
|
|
|
|
}
|
2013-03-30 22:38:24 +08:00
|
|
|
|
2015-09-23 01:22:51 +08:00
|
|
|
// Make sure host-instantiated kernels are preserved on device side.
|
|
|
|
template <typename T> __global__ void templated_kernel(T param) {}
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-DAG: define{{.*}} void @_Z16templated_kernelIiEvT_(
|
2016-05-03 04:30:03 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
__global__ void anonymous_ns_kernel() {}
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-DAG: define{{.*}} void @_ZN12_GLOBAL__N_119anonymous_ns_kernelEv(
|
2016-05-03 04:30:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void host_function() {
|
|
|
|
templated_kernel<<<0, 0>>>(0);
|
|
|
|
anonymous_ns_kernel<<<0,0>>>();
|
|
|
|
}
|
2015-09-23 01:22:51 +08:00
|
|
|
|
2014-12-16 03:10:08 +08:00
|
|
|
// CHECK: !{{[0-9]+}} = !{void ()* @global_function, !"kernel", i32 1}
|
2015-09-23 01:22:51 +08:00
|
|
|
// CHECK: !{{[0-9]+}} = !{void (i32)* @_Z16templated_kernelIiEvT_, !"kernel", i32 1}
|