[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:
Yuta Saito
2020-04-20 14:10:51 +09:00
parent 98522b0b71
commit 915c4a6997
23 changed files with 255 additions and 35 deletions

View File

@@ -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 =