1 // REQUIRES: clang-driver
2 // REQUIRES: x86-registered-target
3 // REQUIRES: nvptx-registered-target
4 
5 // -flto causes a switch to llvm-bc object files.
6 // RUN: %clangxx -nocudainc -nocudalib -ccc-print-phases -c %s -flto 2> %t
7 // RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s
8 //
9 // CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir, (host-cuda)
10 // CHECK-COMPILE-ACTIONS-NOT: lto-bc
11 // CHECK-COMPILE-ACTIONS: 12: backend, {11}, lto-bc, (host-cuda)
12 
13 // RUN: %clangxx -nocudainc -nocudalib -ccc-print-phases %s -flto 2> %t
14 // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s
15 //
16 // CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}lto.cu", cuda, (host-cuda)
17 // CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cuda-cpp-output
18 // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir, (host-cuda)
19 // CHECK-COMPILELINK-ACTIONS: 3: input, "{{.*}}lto.cu", cuda, (device-cuda, sm_20)
20 // CHECK-COMPILELINK-ACTIONS: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_20)
21 // CHECK-COMPILELINK-ACTIONS: 5: compiler, {4}, ir, (device-cuda, sm_20)
22 // CHECK-COMPILELINK-ACTIONS: 6: backend, {5}, assembler, (device-cuda, sm_20)
23 // CHECK-COMPILELINK-ACTIONS: 7: assembler, {6}, object, (device-cuda, sm_20)
24 // CHECK-COMPILELINK-ACTIONS: 8: offload, "device-cuda (nvptx{{.*}}-nvidia-cuda:sm_20)" {7}, object
25 // CHECK-COMPILELINK-ACTIONS: 9: offload, "device-cuda (nvptx{{.*}}-nvidia-cuda:sm_20)" {6}, assembler
26 // CHECK-COMPILELINK-ACTIONS: 10: linker, {8, 9}, cuda-fatbin, (device-cuda)
27 // CHECK-COMPILELINK-ACTIONS: 11: offload, "host-cuda {{.*}}" {2}, "device-cuda{{.*}}" {10}, ir
28 // CHECK-COMPILELINK-ACTIONS: 12: backend, {11}, lto-bc, (host-cuda)
29 // CHECK-COMPILELINK-ACTIONS: 13: linker, {12}, image, (host-cuda)
30 
31 // llvm-bc and llvm-ll outputs need to match regular suffixes
32 // (unfortunately).
33 // RUN: %clangxx %s -nocudainc -nocudalib -flto -save-temps -### 2> %t
34 // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s
35 //
36 // CHECK-COMPILELINK-SUFFIXES: "-o" "[[CPP:.*lto-host.*\.cui]]" "-x" "cuda" "{{.*}}lto.cu"
37 // CHECK-COMPILELINK-SUFFIXES: "-o" "[[BC:.*lto-host.*\.bc]]" {{.*}}[[CPP]]"
38 // CHECK-COMPILELINK-SUFFIXES: "-o" "[[OBJ:.*lto-host.*\.o]]" {{.*}}[[BC]]"
39 // CHECK-COMPILELINK-SUFFIXES: "{{.*}}a.{{(out|exe)}}" {{.*}}[[OBJ]]"
40 
41 // RUN: %clangxx %s -nocudainc -nocudalib -flto -S -### 2> %t
42 // RUN: FileCheck -check-prefix=CHECK-COMPILE-SUFFIXES < %t %s
43 //
44 // CHECK-COMPILE-SUFFIXES: "-o" "{{.*}}lto.s" "-x" "cuda" "{{.*}}lto.cu"
45 
46 // RUN: not %clangxx -nocudainc -nocudalib %s -emit-llvm 2>&1 \
47 // RUN:    | FileCheck --check-prefix=LLVM-LINK %s
48 // LLVM-LINK: -emit-llvm cannot be used when linking
49 
50 /// With ld.bfd or gold, link against LLVMgold.
51 // RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
52 // RUN:   -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
53 // RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
54 // RUN:   -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
55 //
56 // LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
57 
58 /// lld does not need LLVMgold.
59 // RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
60 // RUN:   -fuse-ld=lld -flto=full -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
61 // RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
62 // RUN:   -fuse-ld=gold -flto=full -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
63 //
64 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
65 
66 // -flto passes along an explicit debugger tuning argument.
67 // RUN: %clangxx -nocudainc -nocudalib \
68 // RUN:          -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
69 // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s
70 // RUN: %clangxx -nocudainc -nocudalib \
71 // RUN:          -target x86_64-unknown-linux -### %s -flto -g 2> %t
72 // RUN: FileCheck -check-prefix=CHECK-NO-TUNING < %t %s
73 //
74 // CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
75 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
76