|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -verify -fsyntax-only -std=c++20 %s |
| 2 | + |
| 3 | +// This test validates that this actually makes it through 'MarkDevice'. This |
| 4 | +// is a bit of a pathological case where we ended up visiting each call |
| 5 | +// individually. There is likely a similar test case that can cause us to hit |
| 6 | +// a pathological case in a very similar situation (where the callees aren't |
| 7 | +// exactly the same), but that likely causes problems with template |
| 8 | +// instantiations first. |
| 9 | + |
| 10 | +// expected-no-diagnostics |
| 11 | + |
| 12 | +#include "sycl.hpp" |
| 13 | + |
| 14 | +template<bool B, typename V = void> |
| 15 | +struct enable_if { }; |
| 16 | +template<typename V> |
| 17 | +struct enable_if<true, V> { |
| 18 | + using type = V; |
| 19 | +}; |
| 20 | +template<bool B, typename V = void> |
| 21 | +using enable_if_t = typename enable_if<B, V>::type; |
| 22 | + |
| 23 | + |
| 24 | +template<int N, enable_if_t<N == 24, int> = 0> |
| 25 | +void mark_device_pathological_case() { |
| 26 | + // Do nothing. |
| 27 | +} |
| 28 | + |
| 29 | +template<int N, enable_if_t<N < 24, int> = 0> |
| 30 | +void mark_device_pathological_case() { |
| 31 | + // We were visiting each of these, which caused 9^24 visits. |
| 32 | + mark_device_pathological_case<N + 1>(); |
| 33 | + mark_device_pathological_case<N + 1>(); |
| 34 | + mark_device_pathological_case<N + 1>(); |
| 35 | + mark_device_pathological_case<N + 1>(); |
| 36 | + mark_device_pathological_case<N + 1>(); |
| 37 | + mark_device_pathological_case<N + 1>(); |
| 38 | + mark_device_pathological_case<N + 1>(); |
| 39 | + mark_device_pathological_case<N + 1>(); |
| 40 | + mark_device_pathological_case<N + 1>(); |
| 41 | + mark_device_pathological_case<N + 1>(); |
| 42 | +} |
| 43 | + |
| 44 | +int main() { |
| 45 | + sycl::queue q; |
| 46 | + q.submit([](sycl::handler &h) { |
| 47 | + h.single_task<class kernel>([]() { mark_device_pathological_case<0>(); }); |
| 48 | + }); |
| 49 | +} |
0 commit comments