1// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
3// REQUIRES: amdgpu-registered-target
4
5// If -emit-llvm and/or -S is used in device only compilation,
6// the output should not be bundled.
7
8// RUN: %clang -c -emit-llvm --cuda-device-only -### -target x86_64-linux-gnu \
9// RUN:   -o a.bc -x hip --cuda-gpu-arch=gfx900 \
10// RUN:   --hip-device-lib=lib1.bc \
11// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
12// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
13// RUN: 2>&1 | FileCheck -check-prefixes=CHECK,BC %s
14
15// RUN: %clang -c -S -emit-llvm --cuda-device-only -### -target x86_64-linux-gnu \
16// RUN:   -o a.ll -x hip --cuda-gpu-arch=gfx900 \
17// RUN:   --hip-device-lib=lib1.bc \
18// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
19// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
20// RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LL %s
21
22// RUN: %clang -c -S --cuda-device-only -### -target x86_64-linux-gnu \
23// RUN:   -o a.s -x hip --cuda-gpu-arch=gfx900 \
24// RUN:   --hip-device-lib=lib1.bc \
25// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
26// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
27// RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM %s
28
29// CHECK: {{".*clang.*"}} "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
30// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
31// BC-SAME: "-emit-llvm-bc"
32// LL-SAME: "-emit-llvm"
33// ASM-NOT: "-emit-llvm"
34// CHECK-SAME: "-main-file-name" "a.cu"
35// CHECK-SAME: "-fcuda-is-device"
36// CHECK-SAME: {{".*lib1.bc"}}
37// CHECK-SAME: "-target-cpu" "gfx900"
38// BC-SAME: "-o" "a.bc"
39// LL-SAME: "-o" "a.ll"
40// ASM-SAME: "-o" "a.s"
41// CHECK-SAME: {{".*a.cu"}}
42
43// CHECK-NOT: {{"*.llvm-link"}}
44// CHECK-NOT: {{".*opt"}}
45// CHECK-NOT: {{".*llc"}}
46// CHECK-NOT: {{".*lld.*"}}
47// CHECK-NOT: {{".*clang-offload-bundler"}}
48// CHECK-NOT: {{".*ld.*"}}
49
50// If neither -emit-llvm nor -S is used in device only compilation,
51// the output should be bundled.
52
53// RUN: %clang -c --cuda-device-only -### -target x86_64-linux-gnu \
54// RUN:   -o a.s -x hip --cuda-gpu-arch=gfx900 \
55// RUN:   --hip-device-lib=lib1.bc \
56// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
57// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
58// RUN: 2>&1 | FileCheck -check-prefixes=BUNDLE %s
59
60// RUN: %clang --cuda-device-only -### -target x86_64-linux-gnu \
61// RUN:   -o a.s -x hip --cuda-gpu-arch=gfx900 \
62// RUN:   --hip-device-lib=lib1.bc \
63// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
64// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
65// RUN: 2>&1 | FileCheck -check-prefixes=BUNDLE %s
66
67// BUNDLE: {{"*.clang.*"}} {{.*}} "-emit-obj"
68// BUNDLE-NOT: {{"*.llvm-link"}}
69// BUNDLE-NOT: {{".*opt"}}
70// BUNDLE-NOT: {{".*llc"}}
71// BUNDLE: {{".*lld.*"}}
72// BUNDLE: {{".*clang-offload-bundler"}}
73
74