Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / hip-rdc-device-only.hip
blobd972927ff7a3480af69cac2d1b56875ea1badedf
1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
4 // RUN: %clang -### --target=x86_64-linux-gnu \
5 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
6 // RUN:   -c -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
7 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
8 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
9 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
11 // With `-emit-llvm`, the output should be the same as the aforementioned line
12 // as `-fgpu-rdc` in HIP implies `-emit-llvm`.
14 // RUN: %clang -### --target=x86_64-linux-gnu \
15 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
16 // RUN:   -c -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
17 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
18 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
19 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
21 // With `-fno-hip-emit-relocatable`, the output should be the same as the aforementioned line
22 // as `-fgpu-rdc` in HIP implies `-fno-hip-emit-relocatable`.
24 // RUN: %clang -### --target=x86_64-linux-gnu \
25 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
26 // RUN:   -c -fno-hip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
27 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
28 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
29 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
31 // RUN: %clang -### --target=x86_64-linux-gnu \
32 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
33 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
34 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
35 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
36 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
38 // With `-emit-llvm`, the output should be the same as the aforementioned line
39 // as `-fgpu-rdc` in HIP implies `-emit-llvm`.
41 // RUN: %clang -### --target=x86_64-linux-gnu \
42 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
43 // RUN:   -S -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
44 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
45 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
46 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
48 // With `-save-temps`, commane lines for each steps are dumped. For assembly
49 // output, there should 3 steps (preprocessor, compile, and backend) per source
50 // and per target, totally 12 steps.
52 // RUN: %clang -### -save-temps --target=x86_64-linux-gnu \
53 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
54 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
55 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
56 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
57 // RUN: 2>&1 | FileCheck -check-prefix=SAVETEMP %s
59 // Check output one file without bundling cause error.
61 // RUN: not %clang -### --target=x86_64-linux-gnu \
62 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
63 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
64 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu -o %t.s --no-gpu-bundle-output \
65 // RUN: 2>&1 | FileCheck -check-prefix=FAIL %s
67 // COMMON: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
68 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
69 // EMITBC-SAME: "-emit-llvm-bc"
70 // EMITLL-SAME: "-emit-llvm"
71 // COMMON-SAME: {{.*}} "-main-file-name" "a.cu"
72 // COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
73 // COMMON-SAME: "-fapply-global-visibility-to-externs"
74 // COMMON-SAME: "-target-cpu" "gfx803"
75 // COMMON-SAME: "-fgpu-rdc"
76 // EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
77 // EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
78 // CHECK-SAME: {{.*}} {{".*a.cu"}}
80 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
81 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
82 // EMITBC-SAME: "-emit-llvm-bc"
83 // EMITLL-SAME: "-emit-llvm"
84 // COMMON-SAME: {{.*}} "-main-file-name" "a.cu"
85 // COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
86 // COMMON-SAME: "-fapply-global-visibility-to-externs"
87 // COMMON-SAME: "-target-cpu" "gfx900"
88 // COMMON-SAME: "-fgpu-rdc"
89 // EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
90 // EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
91 // COMMON-SAME: {{.*}} {{".*a.cu"}}
93 // COMMON: "{{.*}}clang-offload-bundler" "-type={{(bc|ll)}}"
94 // COMMON-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
95 // COMMON-SAME: "-output=a-hip-amdgcn-amd-amdhsa.{{(bc|ll)}}"
97 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
98 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
99 // EMITBC-SAME: "-emit-llvm-bc"
100 // EMITLL-SAME: "-emit-llvm"
101 // COMMON-SAME: {{.*}} "-main-file-name" "b.hip"
102 // COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
103 // COMMON-SAME: "-fapply-global-visibility-to-externs"
104 // COMMON-SAME: "-target-cpu" "gfx803"
105 // COMMON-SAME: "-fgpu-rdc"
106 // EMITBC-SAME: {{.*}} "-o" {{".*b.*bc"}} "-x" "hip"
107 // EMITLL-SAME: {{.*}} "-o" {{".*b.*ll"}} "-x" "hip"
108 // COMMON-SAME: {{.*}} {{".*b.hip"}}
110 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
111 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
112 // EMITBC-SAME: "-emit-llvm-bc"
113 // EMITLL-SAME: "-emit-llvm"
114 // COMMON-SAME: {{.*}} "-main-file-name" "b.hip"
115 // COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
116 // COMMON-SAME: "-fapply-global-visibility-to-externs"
117 // COMMON-SAME: "-target-cpu" "gfx900"
118 // COMMON-SAME: "-fgpu-rdc"
119 // EMITBC-SAME: {{.*}} "-o" {{".*b.*bc"}} "-x" "hip"
120 // EMITLL-SAME: {{.*}} "-o" {{".*b.*ll"}} "-x" "hip"
121 // COMMON-SAME: {{.*}} {{".*b.hip"}}
123 // COMMON: "{{.*}}clang-offload-bundler" "-type={{(bc|ll)}}"
124 // COMMON-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
125 // COMMON-SAME: "-output=b-hip-amdgcn-amd-amdhsa.{{(bc|ll)}}"
127 // SAVETEMP: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
128 // SAVETEMP-SAME: "-E"
129 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
130 // SAVETEMP-SAME: {{.*}} "-o" [[A_GFX803_CUI:"a.*hipi"]] "-x" "hip" {{".*a.cu"}}
131 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
132 // SAVETEMP-SAME: "-emit-llvm-bc"
133 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
134 // SAVETEMP-SAME: {{.*}} "-o" [[A_GFX803_TMP_BC:"a.*tmp.bc"]] "-x" "hip-cpp-output" [[A_GFX803_CUI]]
135 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
136 // SAVETEMP-SAME: "-emit-llvm"
137 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
138 // SAVETEMP-SAME: {{.*}} "-o" {{"a.*.ll"}} "-x" "ir" [[A_GFX803_TMP_BC]]
140 // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
141 // SAVETEMP-SAME: "-E"
142 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
143 // SAVETEMP-SAME: {{.*}} "-o" [[A_GFX900_CUI:"a.*hipi"]] "-x" "hip" {{".*a.cu"}}
144 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
145 // SAVETEMP-SAME: "-emit-llvm-bc"
146 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
147 // SAVETEMP-SAME: {{.*}} "-o" [[A_GFX900_TMP_BC:"a.*tmp.bc"]] "-x" "hip-cpp-output" [[A_GFX900_CUI]]
148 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
149 // SAVETEMP-SAME: "-emit-llvm"
150 // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
151 // SAVETEMP-SAME: {{.*}} "-o" {{"a.*.ll"}} "-x" "ir" [[A_GFX900_TMP_BC]]
153 // SAVETEMP: "{{.*}}clang-offload-bundler" "-type=ll"
154 // SAVETEMP-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
155 // SAVETEMP-SAME: "-output=a-hip-amdgcn-amd-amdhsa.ll"
157 // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
158 // SAVETEMP-SAME: "-E"
159 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
160 // SAVETEMP-SAME: {{.*}} "-o" [[B_GFX803_CUI:"b.*hipi"]] "-x" "hip" {{".*b.hip"}}
161 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
162 // SAVETEMP-SAME: "-emit-llvm-bc"
163 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
164 // SAVETEMP-SAME: {{.*}} "-o" [[B_GFX803_TMP_BC:"b.*tmp.bc"]] "-x" "hip-cpp-output" [[B_GFX803_CUI]]
165 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
166 // SAVETEMP-SAME: "-emit-llvm"
167 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
168 // SAVETEMP-SAME: {{.*}} "-o" {{"b.*.ll"}} "-x" "ir" [[B_GFX803_TMP_BC]]
170 // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
171 // SAVETEMP-SAME: "-E"
172 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
173 // SAVETEMP-SAME: {{.*}} "-o" [[B_GFX900_CUI:"b.*hipi"]] "-x" "hip" {{".*b.hip"}}
174 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
175 // SAVETEMP-SAME: "-emit-llvm-bc"
176 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
177 // SAVETEMP-SAME: {{.*}} "-o" [[B_GFX900_TMP_BC:"b.*tmp.bc"]] "-x" "hip-cpp-output" [[B_GFX900_CUI]]
178 // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"
179 // SAVETEMP-SAME: "-emit-llvm"
180 // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
181 // SAVETEMP-SAME: {{.*}} "-o" {{"b.*.ll"}} "-x" "ir" [[B_GFX900_TMP_BC]]
183 // SAVETEMP: "{{.*}}clang-offload-bundler" "-type=ll"
184 // SAVETEMP-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
185 // SAVETEMP-SAME: "-output=b-hip-amdgcn-amd-amdhsa.ll"
187 // FAIL: error: cannot specify -o when generating multiple output files