From 048a0c246908291c82d2f4531d3df45a4c4a8a18 Mon Sep 17 00:00:00 2001 From: Matthew Voss Date: Tue, 11 Jul 2023 15:00:14 -0700 Subject: [clang] Support Unified LTO Bitcode Frontend 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 --- clang/lib/Frontend/CompilerInvocation.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5360bbe..1fba91b 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1767,6 +1767,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.PrepareForThinLTO = true; else if (S != "full") Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S; + if (Args.hasArg(OPT_funified_lto)) + Opts.PrepareForThinLTO = true; } if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) { if (IK.getLanguage() != Language::LLVM_IR) -- cgit v1.1