1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
4 // RUN: %clang -### -target x86_64-linux-gnu -fno-gpu-rdc \
5 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
6 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
7 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
8 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
9 // RUN: -fuse-ld=lld -nogpuinc \
10 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
11 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
12 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LINK %s
14 // RUN: %clang -### -target x86_64-linux-gnu -fno-gpu-rdc \
15 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
16 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
17 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
18 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
19 // RUN: -fuse-ld=lld -nogpuinc -c \
20 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
21 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
22 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
24 // RUN: %clang -### -target x86_64-linux-gnu -fno-gpu-rdc \
25 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
26 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
27 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
28 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
29 // RUN: -fuse-ld=lld -nogpuinc --offload-new-driver -c \
30 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
31 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
32 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
36 // RUN: %clang -### -target x86_64-linux-gnu \
37 // RUN: --hip-link --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
38 // RUN: -fuse-ld=lld -nogpuinc \
39 // RUN: %T/a.o %T/b.o \
40 // RUN: 2>&1 | FileCheck -check-prefixes=LKONLY %s
43 // Compile device code in a.cu to code object for gfx803.
46 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
47 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
48 // CHECK-SAME: "-emit-obj"
49 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
50 // CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
51 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
52 // CHECK-SAME: "-fapply-global-visibility-to-externs"
53 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
54 // CHECK-SAME: "-target-cpu" "gfx803"
55 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_803:".*o"]] "-x" "hip"
56 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
58 // CHECK-NOT: {{".*llvm-link"}}
59 // CHECK-NOT: {{".*opt"}}
60 // CHECK-NOT: {{".*llc"}}
62 // CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
63 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
66 // Compile device code in a.cu to code object for gfx900.
69 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
70 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
71 // CHECK-SAME: "-emit-obj"
72 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
73 // CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
74 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
75 // CHECK-SAME: "-fapply-global-visibility-to-externs"
76 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
77 // CHECK-SAME: "-target-cpu" "gfx900"
78 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_900:".*o"]] "-x" "hip"
79 // CHECK-SAME: {{.*}} [[A_SRC]]
81 // CHECK-NOT: {{".*llvm-link"}}
82 // CHECK-NOT: {{".*opt"}}
83 // CHECK-NOT: {{".*llc"}}
85 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
86 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
89 // Bundle and embed device code in host object for a.cu.
92 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
93 // CHECK-SAME: "-bundle-align=4096"
94 // CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
95 // CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV_A_803]]" "-input=[[IMG_DEV_A_900]]" "-output=[[BUNDLE_A:.*hipfb]]"
97 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
98 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
99 // CHECK-SAME: "-emit-obj"
100 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
101 // CHECK-SAME: {{.*}} "-fcuda-include-gpubinary" "[[BUNDLE_A]]"
102 // CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
103 // CHECK-SAME: {{.*}} [[A_SRC]]
106 // Compile device code in b.hip to code object for gfx803.
109 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
110 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
111 // CHECK-SAME: "-emit-obj"
112 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
113 // CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
114 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
115 // CHECK-SAME: "-fapply-global-visibility-to-externs"
116 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
117 // CHECK-SAME: "-target-cpu" "gfx803"
118 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_B_803:".*o"]] "-x" "hip"
119 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
121 // CHECK-NOT: {{".*llvm-link"}}
122 // CHECK-NOT: {{".*opt"}}
123 // CHECK-NOT: {{".*llc"}}
125 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
126 // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]]
129 // Compile device code in b.hip to code object for gfx900.
132 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
133 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
134 // CHECK-SAME: "-emit-obj"
135 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
136 // CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
137 // CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
138 // CHECK-SAME: "-fapply-global-visibility-to-externs"
139 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
140 // CHECK-SAME: "-target-cpu" "gfx900"
141 // CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_B_900:".*o"]] "-x" "hip"
142 // CHECK-SAME: {{.*}} [[B_SRC]]
144 // CHECK-NOT: {{".*llvm-link"}}
145 // CHECK-NOT: {{".*opt"}}
146 // CHECK-NOT: {{".*llc"}}
148 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
149 // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]]
152 // Bundle and embed device code in host object for b.hip.
155 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
156 // CHECK-SAME: "-bundle-align=4096"
157 // CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
158 // CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV_B_803]]" "-input=[[IMG_DEV_B_900]]" "-output=[[BUNDLE_A:.*hipfb]]"
160 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
161 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
162 // CHECK-SAME: "-emit-obj"
163 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
164 // CHECK-SAME: {{.*}} "-fcuda-include-gpubinary" "[[BUNDLE_A]]"
165 // CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
166 // CHECK-SAME: {{.*}} [[B_SRC]]
169 // Link host objects.
172 // LINK-NOT: {{".*/llvm-link"}}
173 // LINK-NOT: {{".*/opt"}}
174 // LINK-NOT: {{".*/llc"}}
175 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
176 // LINK-NOT: "-T" "{{.*}}.lk"
178 // LKONLY-NOT: {{".*/llvm-link"}}
179 // LKONLY-NOT: {{".*/opt"}}
180 // LKONLY-NOT: {{".*/llc"}}
181 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
182 // LKONLY-NOT: "-T" "{{.*}}.lk"