xref: /aosp_15_r20/external/clang/test/Driver/thinlto.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // -flto=thin causes a switch to llvm-bc object files.
2*67e74705SXin Li // RUN: %clang -ccc-print-phases -c %s -flto=thin 2> %t
3*67e74705SXin Li // RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s
4*67e74705SXin Li //
5*67e74705SXin Li // CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir
6*67e74705SXin Li // CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc
7*67e74705SXin Li 
8*67e74705SXin Li // RUN: %clang -ccc-print-phases %s -flto=thin 2> %t
9*67e74705SXin Li // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s
10*67e74705SXin Li //
11*67e74705SXin Li // CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}thinlto.c", c
12*67e74705SXin Li // CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output
13*67e74705SXin Li // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir
14*67e74705SXin Li // CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc
15*67e74705SXin Li // CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image
16*67e74705SXin Li 
17*67e74705SXin Li // -flto=thin should cause link using gold plugin with thinlto option,
18*67e74705SXin Li // also confirm that it takes precedence over earlier -fno-lto and -flto=full.
19*67e74705SXin Li // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
20*67e74705SXin Li // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
21*67e74705SXin Li //
22*67e74705SXin Li // CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
23*67e74705SXin Li // CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
24*67e74705SXin Li 
25*67e74705SXin Li // Check that subsequent -flto=full takes precedence
26*67e74705SXin Li // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
27*67e74705SXin Li // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
28*67e74705SXin Li //
29*67e74705SXin Li // CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
30*67e74705SXin Li // CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
31*67e74705SXin Li 
32*67e74705SXin Li // Check that subsequent -fno-lto takes precedence
33*67e74705SXin Li // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
34*67e74705SXin Li // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
35*67e74705SXin Li //
36*67e74705SXin Li // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
37*67e74705SXin Li // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"
38