|
| 1 | +// clang-format off |
| 2 | +// : %libomptarget-compileoptxx-generic -fsanitize=offload -O1 |
| 3 | +// : not %libomptarget-run-generic 2> %t.out |
| 4 | +// : %fcheck-generic --check-prefixes=CHECK < %t.out |
| 5 | +// : %libomptarget-compileoptxx-generic -fsanitize=offload -O3 |
| 6 | +// : not %libomptarget-run-generic 2> %t.out |
| 7 | +// RUN: %libomptarget-compileoptxx-generic -fsanitize=offload -O3 -g |
| 8 | +// RUN: not %libomptarget-run-generic 2> %t.out |
| 9 | +// RUN: %fcheck-generic --check-prefixes=DEBUG < %t.out |
| 10 | +// clang-format on |
| 11 | + |
| 12 | +// UNSUPPORTED: aarch64-unknown-linux-gnu |
| 13 | +// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO |
| 14 | +// UNSUPPORTED: x86_64-pc-linux-gnu |
| 15 | +// UNSUPPORTED: x86_64-pc-linux-gnu-LTO |
| 16 | +// UNSUPPORTED: s390x-ibm-linux-gnu |
| 17 | +// UNSUPPORTED: s390x-ibm-linux-gnu-LTO |
| 18 | + |
| 19 | +#include <omp.h> |
| 20 | + |
| 21 | +template <typename T> [[clang::optnone]] T deref(T *P) { return *P; } |
| 22 | + |
| 23 | +template <int LEVEL, typename T> [[gnu::noinline]] T level(T *P) { |
| 24 | + if constexpr (LEVEL > 1) |
| 25 | + return level<LEVEL - 1>(P) + level<LEVEL - 2>(P); |
| 26 | + if constexpr (LEVEL > 0) |
| 27 | + return level<LEVEL - 1>(P); |
| 28 | + return deref(P); |
| 29 | +} |
| 30 | + |
| 31 | +int main(void) { |
| 32 | + |
| 33 | + int *ValidInt = (int *)omp_target_alloc(4, omp_get_default_device()); |
| 34 | +#pragma omp target is_device_ptr(ValidInt) |
| 35 | + { |
| 36 | + level<12>(ValidInt); |
| 37 | + short *ValidShort = ((short *)ValidInt) + 2; |
| 38 | + level<12>(ValidShort); |
| 39 | + char *Invalid = ((char *)ValidInt) + 4; |
| 40 | + level<12>(Invalid); |
| 41 | + } |
| 42 | +} |
0 commit comments