summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCUDA
diff options
context:
space:
mode:
authorJacques Pienaar <jpienaar@google.com>2015-02-24 21:45:33 +0000
committerJacques Pienaar <jpienaar@google.com>2015-02-24 21:45:33 +0000
commita50178c23ed2cb3f0f230ebb7670f47a5cc37bfd (patch)
tree1ec0818c4f9d7ce57b6d7b0711fc98f1d252a5ac /clang/test/CodeGenCUDA
parent7c9442a6aefe268a7714d9ad7a94d6e15d6418f0 (diff)
downloadbcm5719-llvm-a50178c23ed2cb3f0f230ebb7670f47a5cc37bfd.tar.gz
bcm5719-llvm-a50178c23ed2cb3f0f230ebb7670f47a5cc37bfd.zip
CUDA: Add option to allow host device functions to call host functions
Commiting code from review http://reviews.llvm.org/D7841 llvm-svn: 230385
Diffstat (limited to 'clang/test/CodeGenCUDA')
-rw-r--r--clang/test/CodeGenCUDA/host-device-calls-host.cu32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/test/CodeGenCUDA/host-device-calls-host.cu b/clang/test/CodeGenCUDA/host-device-calls-host.cu
new file mode 100644
index 00000000000..8140f619361
--- /dev/null
+++ b/clang/test/CodeGenCUDA/host-device-calls-host.cu
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-allow-host-calls-from-host-device -fcuda-is-device -Wno-cuda-compat -emit-llvm -o - | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+extern "C"
+void host_function() {}
+
+// CHECK-LABEL: define void @hd_function_a
+extern "C"
+__host__ __device__ void hd_function_a() {
+ // CHECK: call void @host_function
+ host_function();
+}
+
+// CHECK: declare void @host_function
+
+// CHECK-LABEL: define void @hd_function_b
+extern "C"
+__host__ __device__ void hd_function_b(bool b) { if (b) host_function(); }
+
+// CHECK-LABEL: define void @device_function_b
+extern "C"
+__device__ void device_function_b() { hd_function_b(false); }
+
+// CHECK-LABEL: define void @global_function
+extern "C"
+__global__ void global_function() {
+ // CHECK: call void @device_function_b
+ device_function_b();
+}
+
+// CHECK: !{{[0-9]+}} = !{void ()* @global_function, !"kernel", i32 1}
OpenPOWER on IntegriCloud