1 // REQUIRES: x86-registered-target
2 // UNSUPPORTED: system-windows
4 // RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=spirv64 \
5 // RUN: -fgpu-rdc --hip-path=%S/Inputs/hipspv -nohipwrapperinc \
6 // RUN: %S/Inputs/hip_multiple_inputs/a.cu \
7 // RUN: %S/Inputs/hip_multiple_inputs/b.hip \
8 // RUN: 2>&1 | FileCheck %s
10 // Emit objects for host side path
11 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
12 // CHECK-SAME: "-aux-triple" "spirv64"
13 // CHECK-SAME: "-emit-obj"
14 // CHECK-SAME: "-fgpu-rdc"
15 // CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
16 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
18 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
19 // CHECK-SAME: "-aux-triple" "spirv64"
20 // CHECK-SAME: "-emit-obj"
21 // CHECK-SAME: "-fgpu-rdc"
22 // CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
23 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
25 // Emit code (LLVM BC) for device side path.
26 // CHECK: [[CLANG]] "-cc1" "-triple" "spirv64"
27 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
28 // CHECK-SAME: "-emit-llvm-bc"
29 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions"
30 // CHECK-SAME: "-fvisibility" "hidden" "-fapply-global-visibility-to-externs"
31 // CHECK-SAME: "-fgpu-rdc"
32 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
33 // CHECK-SAME: {{.*}} [[A_SRC]]
35 // CHECK: [[CLANG]] "-cc1" "-triple" "spirv64"
36 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
37 // CHECK-SAME: "-emit-llvm-bc"
38 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions"
39 // CHECK-SAME: "-fvisibility" "hidden" "-fapply-global-visibility-to-externs"
40 // CHECK-SAME: "-fgpu-rdc"
41 // CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
42 // CHECK-SAME: {{.*}} [[B_SRC]]
44 // Link device code, lower it with HIPSPV passes and emit SPIR-V binary.
45 // CHECK: {{".*llvm-link.*"}} [[A_BC1]] [[B_BC1]] "-o" [[AB_LINK:".*bc"]]
46 // CHECK: {{".*opt.*"}} [[AB_LINK]] "-load-pass-plugin"
47 // CHECK-SAME: "{{.*}}/Inputs/hipspv/lib/libLLVMHipSpvPasses.so"
48 // CHECK-SAME: "-o" [[AB_LOWER:".*bc"]]
49 // CHECK: {{".*llvm-spirv"}} "--spirv-max-version=1.1" "--spirv-ext=+all"
50 // CHECK-SAME: [[AB_LOWER]] "-o" "[[AB_SPIRV:.*out]]"
52 // Construct fat binary object.
53 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o" "-bundle-align=4096"
54 // CHECK-SAME: "-targets={{.*}},hip-spirv64----generic"
55 // CHECK-SAME: "-input=/dev/null" "-input=[[AB_SPIRV]]"
56 // CHECK-SAME: "-output=[[AB_FATBIN:.*hipfb]]"
57 // CHECK: {{".*llvm-mc.*"}} "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin"
58 // CHECK-SAME: "--filetype=obj"
60 // Output the executable
61 // CHECK: {{".*ld.*"}} {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
62 // CHECK-SAME: [[OBJBUNDLE]]