mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-14 09:56:33 +00:00

The unified LTO pipeline creates a single LTO bitcode structure that can be used by Thin or Full LTO. This means that the LTO mode can be chosen at link time and that all LTO bitcode produced by the pipeline is compatible, from an optimization perspective. This makes the behavior of LTO a bit more predictable by normalizing the set of LTO features supported by each LTO bitcode file. Example usage: # Compile and link. Select regular LTO at link time. clang -flto -funified-lto -fuse-ld=lld foo.c # Compile and link. Select ThinLTO at link time. clang -flto=thin -funified-lto -fuse-ld=lld foo.c # Link separately, using ThinLTO. clang -c -flto -funified-lto foo.c # -flto={full,thin} are identical in terms of compilation actions clang -flto=thin -fuse-ld=lld foo.o # pass --lto=thin to ld.lld # Link separately, using regular LTO. clang -c -flto -funified-lto foo.c clang -flto -fuse-ld=lld foo.o # pass --lto=full to ld.lld The RFC discussing the details and rational for this change is here: https://discourse.llvm.org/t/rfc-a-unified-lto-bitcode-frontend/61774
24 lines
1.4 KiB
C
24 lines
1.4 KiB
C
// ; Check that the -flto=thin option emits a ThinLTO summary
|
|
// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s
|
|
// CHECK: <GLOBALVAL_SUMMARY_BLOCK
|
|
//
|
|
// ; Check that we do not emit a summary for regular LTO on Apple platforms
|
|
// RUN: %clang_cc1 -flto -triple x86_64-apple-darwin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTO %s
|
|
// LTO-NOT: GLOBALVAL_SUMMARY_BLOCK
|
|
//
|
|
// ; Check that we emit a summary for regular LTO by default elsewhere
|
|
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s
|
|
// LTOINDEX: <FULL_LTO_GLOBALVAL_SUMMARY_BLOCK
|
|
//
|
|
// ; Simulate -save-temps and check that it works (!"ThinLTO" module flag not added multiple times)
|
|
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes < %s -o %t.bc
|
|
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -x ir < %t.bc | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s
|
|
|
|
/// Check that emitting bitcode works for Unified LTO, when either LTO mode is specified
|
|
// RUN: %clang_cc1 -flto=thin -funified-lto -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=UNITHIN %s
|
|
// RUN: %clang_cc1 -flto -funified-lto -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=UNITHIN %s
|
|
|
|
// UNITHIN: <GLOBALVAL_SUMMARY_BLOCK
|
|
|
|
int main(void) {}
|