Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s |
| 2 | // RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -verify -fcuda-is-device %s |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 3 | // |
| 4 | // We run clang_cc1 with 'not' because source file contains |
| 5 | // intentional errors. CC1 failure is expected and must be ignored |
| 6 | // here. We're interested in what ends up in AST and that's what |
| 7 | // FileCheck verifies. |
| 8 | // RUN: not %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -ast-dump %s \ |
| 9 | // RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-HOST |
| 10 | // RUN: not %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -ast-dump -fcuda-is-device %s \ |
| 11 | // RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-DEVICE |
Peter Collingbourne | 6ab610c | 2010-12-01 03:15:31 +0000 | [diff] [blame] | 12 | |
Eli Bendersky | 3468d9d | 2014-04-28 22:21:28 +0000 | [diff] [blame] | 13 | #include "Inputs/cuda.h" |
Peter Collingbourne | 6ab610c | 2010-12-01 03:15:31 +0000 | [diff] [blame] | 14 | |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 15 | // Host (x86) supports TLS and device-side compilation should ignore |
| 16 | // host variables. No errors in either case. |
| 17 | int __thread host_tls_var; |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 18 | // CHECK-ALL: host_tls_var 'int' tls |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 19 | |
| 20 | #if defined(__CUDA_ARCH__) |
| 21 | // NVPTX does not support TLS |
| 22 | __device__ int __thread device_tls_var; // expected-error {{thread-local storage is not supported for the current target}} |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 23 | // CHECK-DEVICE: device_tls_var 'int' tls |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 24 | __shared__ int __thread shared_tls_var; // expected-error {{thread-local storage is not supported for the current target}} |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 25 | // CHECK-DEVICE: shared_tls_var 'int' tls |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 26 | #else |
| 27 | // Device-side vars should not produce any errors during host-side |
| 28 | // compilation. |
| 29 | __device__ int __thread device_tls_var; |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 30 | // CHECK-HOST: device_tls_var 'int' tls |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 31 | __shared__ int __thread shared_tls_var; |
Artem Belevich | a0473a5 | 2015-04-28 20:31:49 +0000 | [diff] [blame] | 32 | // CHECK-HOST: shared_tls_var 'int' tls |
Artem Belevich | fa62ad4 | 2015-04-27 19:37:53 +0000 | [diff] [blame] | 33 | #endif |
| 34 | |
Peter Collingbourne | 6ab610c | 2010-12-01 03:15:31 +0000 | [diff] [blame] | 35 | __global__ void g1(int x) {} |
Peter Collingbourne | e8cfaf4 | 2010-12-12 23:02:57 +0000 | [diff] [blame] | 36 | __global__ int g2(int x) { // expected-error {{must have void return type}} |
| 37 | return 1; |
| 38 | } |