Clang Project

clang_source_code/test/Driver/thinlto.c
1// -flto=thin causes a switch to llvm-bc object files.
2// RUN: %clang -ccc-print-phases -c %s -flto=thin 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=thin 2> %t
9// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s
10//
11// CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}thinlto.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// -flto=thin should cause link using gold plugin with thinlto option,
18// also confirm that it takes precedence over earlier -fno-lto and -flto=full.
19// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
20// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
21//
22// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
23// CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
24
25// Check that subsequent -flto=full takes precedence
26// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
27// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
28//
29// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
30// CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
31
32// Check that subsequent -fno-lto takes precedence
33// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
34// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
35//
36// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
37// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"
38