Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / openmp-offload-jit.c
blob6f5ae7ed7365d19a0c4ff6294d72b8efe92f41f5
1 // REQUIRES: x86-registered-target
2 // REQUIRES: nvptx-registered-target
3 // REQUIRES: amdgpu-registered-target
5 // Check that we enable LTO-mode properly with '-fopenmp-target-jit' and that it
6 // still enabled LTO-mode if `-fno-offload-lto` is on.
7 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-phases -fopenmp=libomp \
8 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-target-jit %s 2>&1 \
9 // RUN: | FileCheck -check-prefix=PHASES-JIT %s
10 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-phases -fopenmp=libomp \
11 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -foffload-lto -fopenmp-target-jit %s 2>&1 \
12 // RUN: | FileCheck -check-prefix=PHASES-JIT %s
13 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-phases -fopenmp=libomp \
14 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-jit %s 2>&1 \
15 // RUN: | FileCheck -check-prefix=PHASES-JIT %s
16 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-phases -fopenmp=libomp \
17 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa -foffload-lto -fopenmp-target-jit %s 2>&1 \
18 // RUN: | FileCheck -check-prefix=PHASES-JIT %s
19 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-phases -fopenmp=libomp \
20 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa -fno-offload-lto -fopenmp-target-jit %s 2>&1 \
21 // RUN: | FileCheck -check-prefix=PHASES-JIT %s
23 // PHASES-JIT: 0: input, "[[INPUT:.+]]", c, (host-openmp)
24 // PHASES-JIT-NEXT: 1: preprocessor, {0}, cpp-output, (host-openmp)
25 // PHASES-JIT-NEXT: 2: compiler, {1}, ir, (host-openmp)
26 // PHASES-JIT-NEXT: 3: input, "[[INPUT]]", c, (device-openmp)
27 // PHASES-JIT-NEXT: 4: preprocessor, {3}, cpp-output, (device-openmp)
28 // PHASES-JIT-NEXT: 5: compiler, {4}, ir, (device-openmp)
29 // PHASES-JIT-NEXT: 6: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp ([[TARGET:.+]])" {5}, ir
30 // PHASES-JIT-NEXT: 7: backend, {6}, lto-bc, (device-openmp)
31 // PHASES-JIT-NEXT: 8: offload, "device-openmp ([[TARGET]])" {7}, lto-bc
32 // PHASES-JIT-NEXT: 9: clang-offload-packager, {8}, image, (device-openmp)
33 // PHASES-JIT-NEXT: 10: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (x86_64-unknown-linux-gnu)" {9}, ir
34 // PHASES-JIT-NEXT: 11: backend, {10}, assembler, (host-openmp)
35 // PHASES-JIT-NEXT: 12: assembler, {11}, object, (host-openmp)
36 // PHASES-JIT-NEXT: 13: clang-linker-wrapper, {12}, image, (host-openmp)
38 // Check that we add the `--embed-bitcode` flag to the linker wrapper.
39 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
40 // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \
41 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_52 \
42 // RUN: -fopenmp-target-jit %s 2>&1 | FileCheck -check-prefix=LINKER %s
43 // LINKER: clang-linker-wrapper"{{.*}}"--embed-bitcode"
45 // Check for incompatible combinations
47 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fno-offload-lto \
48 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-target-jit %s 2>&1 \
49 // RUN: | FileCheck -check-prefix=NO-LTO %s
50 // NO-LTO: error: the combination of '-fno-offload-lto' and '-fopenmp-target-jit' is incompatible
52 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -foffload-lto=thin \
53 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-target-jit %s 2>&1 \
54 // RUN: | FileCheck -check-prefix=THIN-LTO %s
55 // THIN-LTO: error: the combination of '-foffload-lto=' and '-fopenmp-target-jit' is incompatible