Skip to content

Commit c48fb78

Browse files
committed
[SYCL] Add initial test for sycl-device-only
1 parent 18587fc commit c48fb78

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKD
2+
// RUN: %clang_cc1 -fsycl-is-host -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKH
3+
// Test code generation for sycl_device_only attribute.
4+
5+
// CHECK-LABEL: _Z3fooi
6+
// CHECKH: %add = add nsw i32 %0, 10
7+
// CHECKD: %add = add nsw i32 %0, 20
8+
int foo(int a) { return a + 10; }
9+
10+
#ifdef __SYCL_DEVICE_ONLY__
11+
__attribute__((sycl_device_only)) int foo(int a) { return a + 20; }
12+
#endif
13+
14+
__attribute__((sycl_device)) int bar(int b) {
15+
return foo(b);
16+
}
17+
18+
extern "C" {
19+
// CHECK-LABEL: _Z3fooci
20+
// CHECKH: %add = add nsw i32 %0, 10
21+
// CHECKD: %add = add nsw i32 %0, 20
22+
int fooc(int a) { return a + 10; }
23+
#ifdef __SYCL_DEVICE_ONLY__
24+
__attribute__((sycl_device_only)) int fooc(int a) { return a + 20; }
25+
#endif
26+
27+
__attribute__((sycl_device)) int barc(int b) {
28+
return fooc(b);
29+
}
30+
}

0 commit comments

Comments
 (0)