Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / hip-device-compile.hip
blob3c3e3878562474851d3b33eea3940861e15d7156
1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
4 // If -emit-llvm and/or -S is used in device only compilation,
5 // the output should not be bundled, except --gpu-bundle-output
6 // is specified.
8 // Output unbundled bitcode.
9 // RUN: %clang -c -emit-llvm --cuda-device-only -### --target=x86_64-linux-gnu \
10 // RUN:   --rocm-path=%S/Inputs/rocm -o a.bc -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
11 // RUN:   --hip-device-lib=lib1.bc \
12 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
13 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
14 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,BC,NBUN %s
16 // Output bundled bitcode.
17 // RUN: %clang -c -emit-llvm --cuda-device-only -### --target=x86_64-linux-gnu \
18 // RUN:   --rocm-path=%S/Inputs/rocm -o a.bc -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
19 // RUN:   --hip-device-lib=lib1.bc \
20 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
21 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu --gpu-bundle-output \
22 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,BCBUN %s
24 // Output unbundled LLVM IR.
25 // RUN: %clang -c -S -emit-llvm --cuda-device-only -### --target=x86_64-linux-gnu \
26 // RUN:   --rocm-path=%S/Inputs/rocm -o a.ll -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
27 // RUN:   --hip-device-lib=lib1.bc \
28 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
29 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
30 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LL,NBUN %s
32 // Output bundled LLVM IR.
33 // RUN: %clang -c -S -emit-llvm --cuda-device-only -### --target=x86_64-linux-gnu \
34 // RUN:   --rocm-path=%S/Inputs/rocm -o a.ll -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
35 // RUN:   --hip-device-lib=lib1.bc \
36 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
37 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu --gpu-bundle-output \
38 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LLBUN %s
40 // Output unbundled assembly.
41 // RUN: %clang -c -S --cuda-device-only -### --target=x86_64-linux-gnu \
42 // RUN:   --rocm-path=%S/Inputs/rocm -o a.s -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
43 // RUN:   --hip-device-lib=lib1.bc \
44 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
45 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
46 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM,NBUN %s
48 // Output relocatable.
49 // RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
50 // RUN:   --rocm-path=%S/Inputs/rocm -o a.o -x hip --cuda-gpu-arch=gfx900 -fhip-emit-relocatable \
51 // RUN:   --hip-device-lib=lib1.bc \
52 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
53 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
54 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,NBUN,RELOC %s
56 // Output bundled assembly.
57 // RUN: %clang -c -S --cuda-device-only -### --target=x86_64-linux-gnu \
58 // RUN:   --rocm-path=%S/Inputs/rocm -o a.s -x hip --cuda-gpu-arch=gfx900 --no-gpu-bundle-output \
59 // RUN:   --hip-device-lib=lib1.bc \
60 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
61 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu --gpu-bundle-output \
62 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASMBUN %s
64 // CHECK: {{".*clang.*"}} "-cc1" "-triple" "amdgcn-amd-amdhsa"
65 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
66 // BC-SAME: "-emit-llvm-bc"
67 // LL-SAME: "-emit-llvm"
68 // ASM-NOT: "-emit-llvm"
69 // CHECK-SAME: "-main-file-name" "a.cu"
70 // CHECK-SAME: "-fcuda-is-device"
71 // CHECK-SAME: {{".*lib1.bc"}}
72 // CHECK-SAME: "-target-cpu" "gfx900"
73 // BC-SAME: "-o" "a.bc"
74 // BCBUN-SAME: "-o" "{{.*}}.bc"
75 // LL-SAME: "-o" "a.ll"
76 // LLBUN-SAME: "-o" "{{.*}}.ll"
77 // ASM-SAME: "-o" "a.s"
78 // ASMBUN-SAME: "-o" "{{.*}}.s"
79 // RELOC-SAME: "-o" "a.o"
80 // CHECK-SAME: {{".*a.cu"}}
82 // CHECK-NOT: {{"*.llvm-link"}}
83 // CHECK-NOT: {{".*opt"}}
84 // CHECK-NOT: {{".*llc"}}
85 // CHECK-NOT: {{".*lld.*"}}
86 // NBUN-NOT: {{".*clang-offload-bundler"}}
87 // BCBUN: {{".*clang-offload-bundler"}}{{.*}}"-output=a.bc"
88 // LLBUN: {{".*clang-offload-bundler"}}{{.*}}"-output=a.ll"
89 // ASMBUN: {{".*clang-offload-bundler"}}{{.*}}"-output=a.s"
90 // CHECK-NOT: {{".*ld.*"}}{{.*}}"-o"
92 // If neither -emit-llvm nor -S is used in device only compilation,
93 // the output should be bundled except --no-gpu-bundle-output is
94 // specified.
96 // Output bundled code objects.
97 // RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
98 // RUN:   --rocm-path=%S/Inputs/rocm -o a.o -x hip --cuda-gpu-arch=gfx900 \
99 // RUN:   --hip-device-lib=lib1.bc \
100 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
101 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
102 // RUN: 2>&1 | FileCheck -check-prefixes=OBJ,OBJ-BUN %s
104 // Output unbundled code objects.
105 // RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
106 // RUN:   --rocm-path=%S/Inputs/rocm -o a.o -x hip --cuda-gpu-arch=gfx900 \
107 // RUN:   --hip-device-lib=lib1.bc \
108 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
109 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu --no-gpu-bundle-output \
110 // RUN: 2>&1 | FileCheck -check-prefixes=OBJ,OBJ-UBUN %s
112 // Output bundled code objects.
113 // RUN: %clang --cuda-device-only -### --target=x86_64-linux-gnu \
114 // RUN:   --rocm-path=%S/Inputs/rocm -o a.o -x hip --cuda-gpu-arch=gfx900 \
115 // RUN:   --hip-device-lib=lib1.bc \
116 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
117 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
118 // RUN: 2>&1 | FileCheck -check-prefixes=OBJ,OBJ-BUN %s
120 // Output unbundled code objects.
121 // RUN: %clang --cuda-device-only -### --target=x86_64-linux-gnu \
122 // RUN:   --rocm-path=%S/Inputs/rocm -o a.o -x hip --cuda-gpu-arch=gfx900 \
123 // RUN:   --hip-device-lib=lib1.bc \
124 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
125 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu --no-gpu-bundle-output \
126 // RUN: 2>&1 | FileCheck -check-prefixes=OBJ,OBJ-UBUN %s
128 // OBJ: {{"*.clang.*"}} {{.*}} "-emit-obj"
129 // OBJ-NOT: {{"*.llvm-link"}}
130 // OBJ-NOT: {{".*opt"}}
131 // OBJ-NOT: {{".*llc"}}
132 // OBJ-BUN: {{".*lld.*"}}{{.*}}"-o" "{{.*}}.o"
133 // OBJ-UBUN: {{".*lld.*"}}{{.*}}"-o" "a.o"
134 // OBJ-BUN: {{".*clang-offload-bundler"}}{{.*}}"-output=a.o"
135 // OBJ-UBUN-NOT: {{".*clang-offload-bundler"}}