1 // RUN: rm -rf %t && mkdir %t
2 // RUN: %clang -### --target=x86_64-linux-gnu -fno-gpu-rdc \
3 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
4 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
5 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
6 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
7 // RUN: -fuse-ld=lld -B%S/Inputs/lld -nogpuinc \
8 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
9 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
10 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LINK %s
12 // RUN: %clang -### --target=x86_64-linux-gnu -fno-gpu-rdc \
13 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
14 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
15 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
16 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
17 // RUN: -fuse-ld=lld -B%S/Inputs/lld -nogpuinc -c \
18 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
19 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
20 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
22 // RUN: %clang -### --target=x86_64-linux-gnu -fno-gpu-rdc \
23 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
24 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
25 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
26 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
27 // RUN: -fuse-ld=lld -B%S/Inputs/lld -nogpuinc --offload-new-driver -c \
28 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
29 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
30 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
32 // RUN: touch %t/a.o %t/b.o
33 // RUN: %clang -### --target=x86_64-linux-gnu \
34 // RUN: --hip-link --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
35 // RUN: -fuse-ld=lld -B%S/Inputs/lld -nogpuinc \
36 // RUN: %t/a.o %t/b.o \
37 // RUN: 2>&1 | FileCheck -check-prefixes=LKONLY %s
39 // RUN: %clang -### --target=x86_64-linux-gnu \
40 // RUN: --offload-arch=amdgcnspirv --offload-arch=gfx900 \
41 // RUN: %s -nogpuinc -nogpulib \
42 // RUN: 2>&1 | FileCheck -check-prefixes=AMDGCNSPIRV %s
45 // Compile device code in a.cu to code object for gfx803.
48 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
49 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
50 // CHECK-SAME: "-emit-obj"
51 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
52 // CHECK-SAME: "-fcuda-is-device" "-fno-threadsafe-statics" "-mllvm" "-amdgpu-internalize-symbols"
53 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
54 // CHECK-SAME: "-fapply-global-visibility-to-externs"
55 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
56 // CHECK-SAME: "-target-cpu" "gfx803"
57 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_803:".*o"]] "-x" "hip"
58 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
60 // CHECK-NOT: {{".*llvm-link"}}
61 // CHECK-NOT: {{".*opt"}}
62 // CHECK-NOT: {{".*llc"}}
64 // CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "-m" "elf64_amdgpu" "--no-undefined" "-shared"
65 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
68 // Compile device code in a.cu to code object for gfx900.
71 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
72 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
73 // CHECK-SAME: "-emit-obj"
74 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
75 // CHECK-SAME: "-fcuda-is-device" "-fno-threadsafe-statics" "-mllvm" "-amdgpu-internalize-symbols"
76 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
77 // CHECK-SAME: "-fapply-global-visibility-to-externs"
78 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
79 // CHECK-SAME: "-target-cpu" "gfx900"
80 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_900:".*o"]] "-x" "hip"
81 // CHECK-SAME: {{.*}} [[A_SRC]]
83 // CHECK-NOT: {{".*llvm-link"}}
84 // CHECK-NOT: {{".*opt"}}
85 // CHECK-NOT: {{".*llc"}}
87 // CHECK: [[LLD]] "-flavor" "gnu" "-m" "elf64_amdgpu" "--no-undefined" "-shared"
88 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
91 // Bundle and embed device code in host object for a.cu.
94 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
95 // CHECK-SAME: "-bundle-align=4096"
96 // CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
97 // CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV_A_803]]" "-input=[[IMG_DEV_A_900]]" "-output=[[BUNDLE_A:.*hipfb]]"
99 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
100 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
101 // CHECK-SAME: "-emit-obj"
102 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
103 // CHECK-SAME: {{.*}} "-fcuda-include-gpubinary" "[[BUNDLE_A]]"
104 // CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
105 // CHECK-SAME: {{.*}} [[A_SRC]]
108 // Compile device code in b.hip to code object for gfx803.
111 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
112 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
113 // CHECK-SAME: "-emit-obj"
114 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
115 // CHECK-SAME: "-fcuda-is-device" "-fno-threadsafe-statics" "-mllvm" "-amdgpu-internalize-symbols"
116 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
117 // CHECK-SAME: "-fapply-global-visibility-to-externs"
118 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
119 // CHECK-SAME: "-target-cpu" "gfx803"
120 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_B_803:".*o"]] "-x" "hip"
121 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
123 // CHECK-NOT: {{".*llvm-link"}}
124 // CHECK-NOT: {{".*opt"}}
125 // CHECK-NOT: {{".*llc"}}
127 // CHECK: [[LLD]] "-flavor" "gnu" "-m" "elf64_amdgpu" "--no-undefined" "-shared"
128 // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]]
131 // Compile device code in b.hip to code object for gfx900.
134 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
135 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
136 // CHECK-SAME: "-emit-obj"
137 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
138 // CHECK-SAME: "-fcuda-is-device" "-fno-threadsafe-statics" "-mllvm" "-amdgpu-internalize-symbols"
139 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
140 // CHECK-SAME: "-fapply-global-visibility-to-externs"
141 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
142 // CHECK-SAME: "-target-cpu" "gfx900"
143 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_B_900:".*o"]] "-x" "hip"
144 // CHECK-SAME: {{.*}} [[B_SRC]]
146 // CHECK-NOT: {{".*llvm-link"}}
147 // CHECK-NOT: {{".*opt"}}
148 // CHECK-NOT: {{".*llc"}}
150 // CHECK: [[LLD]] "-flavor" "gnu" "-m" "elf64_amdgpu" "--no-undefined" "-shared"
151 // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]]
154 // Bundle and embed device code in host object for b.hip.
157 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
158 // CHECK-SAME: "-bundle-align=4096"
159 // CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
160 // CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV_B_803]]" "-input=[[IMG_DEV_B_900]]" "-output=[[BUNDLE_A:.*hipfb]]"
162 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
163 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
164 // CHECK-SAME: "-emit-obj"
165 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
166 // CHECK-SAME: {{.*}} "-fcuda-include-gpubinary" "[[BUNDLE_A]]"
167 // CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
168 // CHECK-SAME: {{.*}} [[B_SRC]]
171 // Link host objects.
174 // LINK-NOT: {{".*/llvm-link"}}
175 // LINK-NOT: {{".*/opt"}}
176 // LINK-NOT: {{".*/llc"}}
177 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
178 // LINK-NOT: "-T" "{{.*}}.lk"
180 // LKONLY-NOT: {{".*/llvm-link"}}
181 // LKONLY-NOT: {{".*/opt"}}
182 // LKONLY-NOT: {{".*/llc"}}
183 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
184 // LKONLY-NOT: "-T" "{{.*}}.lk"
187 // Check mixed AMDGCNSPIRV and concrete GPU arch.
190 // AMDGCNSPIRV: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-emit-obj" {{.*}} "-o" "[[AMDGCNSPV_OBJ:.*o]]"
191 // AMDGCNSPIRV: {{".*llvm-link.*"}} "-o" "[[AMDGCNSPV_TMP:.*out]]" "[[AMDGCNSPV_OBJ]]"
192 // AMDGCNSPIRV: {{".*llvm-spirv.*"}} "--spirv-max-version=1.6" "--spirv-ext=+all" {{.*}} "[[AMDGCNSPV_TMP]]" {{.*}}"-o" "[[AMDGCNSPV_CO:.*out]]"
193 // AMDGCNSPIRV: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}}"-emit-obj" {{.*}}"-target-cpu" "gfx900"{{.*}} "-o" "[[GFX900_OBJ:.*o]]"
194 // AMDGCNSPIRV: {{".*lld.*"}} {{.*}}"-plugin-opt=mcpu=gfx900" {{.*}} "-o" "[[GFX900_CO:.*out]]" {{.*}}"[[GFX900_OBJ]]"
195 // AMDGCNSPIRV: {{".*clang-offload-bundler.*"}} "-type=o"
196 // AMDGCNSPIRV-SAME: "-targets={{.*}}hipv4-spirv64-amd-amdhsa--amdgcnspirv,hipv4-amdgcn-amd-amdhsa--gfx900"
197 // AMDGCNSPIRV-SAME: "-input=[[AMDGCNSPV_CO]]" "-input=[[GFX900_CO]]"