[PATCH] D99126: [darwin][driver] Pass through -global-isel LLVM flags to ld.
Amara Emerson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 22 16:57:32 PDT 2021
aemerson created this revision.
aemerson added reviewers: paquette, ahmed, qcolombet, pete.
aemerson added a project: clang.
Herald added subscribers: steven_wu, hiraditya.
aemerson requested review of this revision.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99126
Files:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-lto.c
Index: clang/test/Driver/darwin-ld-lto.c
===================================================================
--- clang/test/Driver/darwin-ld-lto.c
+++ clang/test/Driver/darwin-ld-lto.c
@@ -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"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -373,6 +373,18 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99126.332475.patch
Type: text/x-patch
Size: 1579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210322/49835175/attachment.bin>
More information about the cfe-commits
mailing list