mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[LTO] Support LLVM level link time optimization
This commit adds -lto flag for driver to enable LTO at LLVM level. When -lto=llvm given, compiler emits LLVM bitcode file instead of object file and perform thin LTO using libLTO.dylib plugin. When -lto=llvm-full given, perform full LTO instead of thin LTO.
This commit is contained in:
@@ -1421,6 +1421,17 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
}
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_lto)) {
|
||||
auto LLVMLTOKind = llvm::StringSwitch<Optional<IRGenLLVMLTOKind>>(A->getValue())
|
||||
.Case("llvm", IRGenLLVMLTOKind::Thin)
|
||||
.Case("llvm-full", IRGenLLVMLTOKind::Full)
|
||||
.Default(llvm::None);
|
||||
if (LLVMLTOKind)
|
||||
Opts.LLVMLTOKind = LLVMLTOKind.getValue();
|
||||
else
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||
A->getAsString(Args), A->getValue());
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) {
|
||||
Opts.SanitizeCoverage =
|
||||
|
||||
Reference in New Issue
Block a user