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: --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 -fgpu-rdc -nogpuinc \
10 // RUN: -fhip-dump-offload-linker-script \
11 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
12 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
13 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LNX %s
15 // RUN: %clang -### --target=x86_64-pc-windows-msvc \
16 // RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
17 // RUN: --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
18 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
19 // RUN: --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
20 // RUN: -fuse-ld=lld -fgpu-rdc -nogpuinc \
21 // RUN: -fhip-dump-offload-linker-script \
22 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
23 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
24 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,MSVC %s
26 // check code object alignment in dumped llvm-mc input
27 // LNX: .protected __hip_fatbin
28 // LNX: .type __hip_fatbin,@object
29 // LNX: .section .hip_fatbin,"a",@progbits
30 // MSVC: .section .hip_fatbin, "dw"
31 // CHECK: .globl __hip_fatbin
33 // CHECK: __hip_fatbin:
34 // CHECK: .incbin "[[BUNDLE:.*hipfb]]"
36 // emit objects for host side path
37 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" [[HOST:"x86_64-[^"]+"]]
38 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
39 // CHECK-SAME: "-emit-obj"
40 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
41 // CHECK-SAME: "-fgpu-rdc"
42 // CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
43 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
45 // CHECK: [[CLANG]] "-cc1" "-triple" [[HOST]]
46 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
47 // CHECK-SAME: "-emit-obj"
48 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
49 // CHECK-SAME: "-fgpu-rdc"
50 // CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
51 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
53 // generate image for device side path on gfx803
54 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
55 // CHECK-SAME: "-aux-triple" [[HOST:"x86_64-[^"]+"]]
56 // CHECK-SAME: "-emit-llvm-bc"
57 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
58 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
59 // CHECK-SAME: "-fapply-global-visibility-to-externs"
60 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
61 // CHECK-SAME: "-target-cpu" "gfx803"
62 // CHECK-SAME: "-fgpu-rdc"
63 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
64 // CHECK-SAME: {{.*}} [[A_SRC]]
66 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
67 // CHECK-SAME: "-aux-triple" [[HOST]]
68 // CHECK-SAME: "-emit-llvm-bc"
69 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
70 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
71 // CHECK-SAME: "-fapply-global-visibility-to-externs"
72 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
73 // CHECK-SAME: "-target-cpu" "gfx803"
74 // CHECK-SAME: "-fgpu-rdc"
75 // CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
76 // CHECK-SAME: {{.*}} [[B_SRC]]
78 // CHECK-NOT: "*.llvm-link"
81 // CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
82 // CHECK-SAME: "-plugin-opt=mcpu=gfx803"
83 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
85 // generate image for device side path on gfx900
86 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
87 // CHECK-SAME: "-aux-triple" [[HOST]]
88 // CHECK-SAME: "-emit-llvm-bc"
89 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
90 // CHECK-SAME: "-fcuda-is-device"
91 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
92 // CHECK-SAME: "-target-cpu" "gfx900"
93 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
94 // CHECK-SAME: {{.*}} [[A_SRC]]
96 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
97 // CHECK-SAME: "-aux-triple" [[HOST]]
98 // CHECK-SAME: "-emit-llvm-bc"
99 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
100 // CHECK-SAME: "-fcuda-is-device"
101 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
102 // CHECK-SAME: "-target-cpu" "gfx900"
103 // CHECK-SAME: "-fgpu-rdc"
104 // CHECK-SAME: {{.*}} "-o" [[B_BC2:".*bc"]] "-x" "hip"
105 // CHECK-SAME: {{.*}} [[B_SRC]]
107 // CHECK-NOT: "*.llvm-link"
108 // CHECK-NOT: ".*opt"
109 // CHECK-NOT: ".*llc"
110 // CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
111 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
112 // CHECK-SAME: "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
114 // combine images generated into hip fat binary object
115 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
116 // CHECK-SAME: "-bundle-align=4096"
117 // CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
118 // CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV1]]" "-input=[[IMG_DEV2]]" "-output=[[BUNDLE]]"
120 // CHECK: [[MC:".*llvm-mc.*"]] "-triple" [[HOST]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
122 // output the executable
123 // LNX: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
124 // MSVC: [[LD:".*lld-link.*"]] {{.*}}"-out:a.exe" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]