1 | // -flto causes a switch to llvm-bc object files. |
2 | // RUN: %clang -ccc-print-phases -c %s -flto 2> %t |
3 | // RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s |
4 | // |
5 | // CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir |
6 | // CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc |
7 | |
8 | // RUN: %clang -ccc-print-phases %s -flto 2> %t |
9 | // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s |
10 | // |
11 | // CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}lto.c", c |
12 | // CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output |
13 | // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir |
14 | // CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc |
15 | // CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image |
16 | |
17 | // llvm-bc and llvm-ll outputs need to match regular suffixes |
18 | // (unfortunately). |
19 | // RUN: %clang %s -flto -save-temps -### 2> %t |
20 | // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s |
21 | // |
22 | // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.i" "-x" "c" "{{.*}}lto.c" |
23 | // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.bc" {{.*}}"{{.*}}lto.i" |
24 | // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.o" {{.*}}"{{.*}}lto.bc" |
25 | // CHECK-COMPILELINK-SUFFIXES: "{{.*}}a.{{(out|exe)}}" {{.*}}"{{.*}}lto.o" |
26 | |
27 | // RUN: %clang %s -flto -S -### 2> %t |
28 | // RUN: FileCheck -check-prefix=CHECK-COMPILE-SUFFIXES < %t %s |
29 | // |
30 | // CHECK-COMPILE-SUFFIXES: "-o" "{{.*}}lto.s" "-x" "c" "{{.*}}lto.c" |
31 | |
32 | // RUN: not %clang %s -emit-llvm 2>&1 | FileCheck --check-prefix=LLVM-LINK %s |
33 | // LLVM-LINK: -emit-llvm cannot be used when linking |
34 | |
35 | // -flto should cause link using gold plugin |
36 | // RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t |
37 | // RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s |
38 | // |
39 | // CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" |
40 | |
41 | // -flto=full should cause link using gold plugin |
42 | // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t |
43 | // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s |
44 | // |
45 | // CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" |
46 | |
47 | // Check that subsequent -fno-lto takes precedence |
48 | // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t |
49 | // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s |
50 | // |
51 | // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" |
52 | |
53 | // -flto passes along an explicit debugger tuning argument. |
54 | // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t |
55 | // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s |
56 | // RUN: %clang -target x86_64-unknown-linux -### %s -flto -g 2> %t |
57 | // RUN: FileCheck -check-prefix=CHECK-NO-TUNING < %t %s |
58 | // |
59 | // CHECK-TUNING-LLDB: "-plugin-opt=-debugger-tune=lldb" |
60 | // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune |
61 | |