|
| 1 | +// Tests that the llvm.compiler.used symbol, which is used to implement static |
| 2 | +// device globals, is removed at some point in compilation. For SPIR-V this |
| 3 | +// symbol is removed at sycl-post-link and for NVPTX/AMDGCN it is removed at |
| 4 | +// lowering. |
| 5 | +// |
| 6 | +// It also checks that the symbol can be found in an object file for a given |
| 7 | +// triple, thus validating that `llvm-strings` can successfully be used to |
| 8 | +// check for the presence of the symbol. |
| 9 | + |
| 10 | +// UNSUPPORTED: windows |
| 11 | + |
| 12 | +// RUN: %clangxx -fsycl -fsycl-device-only %s -o %t |
| 13 | +// RUN: llvm-strings %t | grep "llvm.compiler.used" |
| 14 | +// RUN: %clangxx -fsycl %s -o %t |
| 15 | +// RUN: llvm-strings %t | not grep "llvm.compiler.used" |
| 16 | + |
| 17 | +// RUN: %if cuda %{ %clangxx -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda %s -o %t %} |
| 18 | +// RUN: %if cuda %{ llvm-strings %t | grep "llvm.compiler.used" %} |
| 19 | +// RUN: %if cuda %{ %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda %s -o %t %} |
| 20 | +// RUN: %if cuda %{ llvm-strings %t | not grep "llvm.compiler.used" %} |
| 21 | + |
| 22 | +// RUN: %if hip_amd %{ %clangxx -fsycl -fsycl-device-only -fsycl-targets=amd_gpu_gfx906 %s -o %t %} |
| 23 | +// RUN: %if hip_amd %{ llvm-strings %t | grep "llvm.compiler.used" %} |
| 24 | +// RUN: %if hip_amd %{ %clangxx -fsycl -fsycl-targets=amd_gpu_gfx906 %s -o %t %} |
| 25 | +// RUN: %if hip_amd %{ llvm-strings %t | not grep "llvm.compiler.used" %} |
| 26 | + |
| 27 | +#include <sycl/sycl.hpp> |
| 28 | + |
| 29 | +using namespace sycl; |
| 30 | +using namespace sycl::ext::oneapi::experimental; |
| 31 | + |
| 32 | +static device_global<int> DeviceGlobalVar; |
| 33 | + |
| 34 | +int main() { |
| 35 | + sycl::queue{}.single_task([=] { volatile int ReadVal = DeviceGlobalVar; }); |
| 36 | +} |
0 commit comments