|
| 1 | +// Test checks Propagate Aspect Usage pass. |
| 2 | + |
| 3 | +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix CHECK-WARNINGS |
| 4 | + |
| 5 | +// RUNx: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown %s -debug-info-kind=constructor -dwarf-version=5 -emit-llvm -o /dev/null 2>&1 | FileCheck %s --check-prefix CHECK-WARNINGS-DBG -DPATH=%s |
| 6 | + |
| 7 | +// CHECK-WARNINGS: warning: function 'func1(int)' uses aspect 'fp16' not listed in 'sycl::device_has()' |
| 8 | +// CHECK-WARNINGS-NEXT: note: the actual use is in func3(int, int, int), compile with '-g' to get source location |
| 9 | +// CHECK-WARNINGS-NEXT: note: which is called by func2(int, int), compile with '-g' to get source location |
| 10 | +// CHECK-WARNINGS-NEXT: note: which is called by func1(int), compile with '-g' to get source location |
| 11 | +// |
| 12 | +// CHECK-WARNINGS-DBG: warning: function 'func1(int)' uses aspect 'fp16' not listed in 'sycl::device_has()' |
| 13 | +// CHECK-WARNINGS-DBG-NEXT: note: the actual use is in func3(int, int, int) at [[PATH]]:36:5 |
| 14 | +// CHECK-WARNINGS-DBG-NEXT: note: which is called by func2(int, int) at [[PATH]]:40:34 |
| 15 | +// CHECK-WARNINGS-DBG-NEXT: note: which is called by func1(int) at [[PATH]]:42:62 |
| 16 | + |
| 17 | +#include "Inputs/sycl.hpp" |
| 18 | + |
| 19 | +using namespace cl::sycl; |
| 20 | + |
| 21 | +class KernelName; |
| 22 | + |
| 23 | +struct [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] Struct { |
| 24 | + int a = 0; |
| 25 | +}; |
| 26 | + |
| 27 | +int func3(int a, int b, int c) { |
| 28 | + Struct s; |
| 29 | + s.a = 1; |
| 30 | + return s.a; |
| 31 | +} |
| 32 | + |
| 33 | +int func2(int a, int b) { return func3(a, b, 1); } |
| 34 | + |
| 35 | +[[sycl::device_has(aspect::fp64)]] int func1(int a) { return func2(a, 1); } |
| 36 | + |
| 37 | +int main() { |
| 38 | + queue Q; |
| 39 | + Q.submit([&](handler &h) { |
| 40 | + h.single_task<KernelName>([=]() { int a = func1(1); }); |
| 41 | + }); |
| 42 | +} |
0 commit comments