[darwin][driver] Pass through -global-isel LLVM flags to ld.

GlobalISel is currently not enabled when using -flto since the front-end
-mvllm flags don't get passed through. This change fixes this for Darwin
platforms. We have to do this in the driver because the code generator choice
isn't embedded into the bitcode file.

Differential Revision: https://reviews.llvm.org/D99126
This commit is contained in:
Amara Emerson 2021-03-22 16:52:11 -07:00
parent 289ecccadd
commit 66af90b46e
2 changed files with 20 additions and 0 deletions

View File

@ -373,6 +373,18 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
}
// If GlobalISel is enabled, pass it through to LLVM.
if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
options::OPT_fno_global_isel)) {
if (A->getOption().matches(options::OPT_fglobal_isel)) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-global-isel");
// Disable abort and fall back to SDAG silently.
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-global-isel-abort=0");
}
}
Args.AddLastArg(CmdArgs, options::OPT_prebind);
Args.AddLastArg(CmdArgs, options::OPT_noprebind);
Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding);

View File

@ -30,3 +30,11 @@
// THIN_LTO_OBJECT_PATH: {{ld(.exe)?"}}
// THIN_LTO_OBJECT_PATH-SAME: "-object_path_lto"
// THIN_LTO_OBJECT_PATH-SAME: {{thinlto\-[a-zA-Z0-9_]+}}
// Check that we pass through -fglobal-isel flags to libLTO.
// RUN: %clang -target arm64-apple-darwin %s -flto -fglobal-isel -### 2>&1 | \
// RUN: FileCheck --check-prefix=GISEL %s
// GISEL: {{ld(.exe)?"}}
// GISEL: "-mllvm" "-global-isel"
// GISEL: "-mllvm" "-global-isel-abort=0"