Skip to content

Commit ebf4c69

Browse files
authored
[Clang][LTO][GISel] Propagate -fglobal-siel to LTO (#69747)
Translate `-fglobal-isel` to `-plugin-opt=-global-isel=1`.
1 parent 513b950 commit ebf4c69

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,16 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
694694
CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
695695
ParallelismOpt + Parallelism));
696696

697+
// Pass down GlobalISel options.
698+
if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
699+
options::OPT_fno_global_isel)) {
700+
// Parsing -fno-global-isel explicitly gives architectures that enable GISel
701+
// by default a chance to disable it.
702+
CmdArgs.push_back(Args.MakeArgString(
703+
Twine(PluginOptPrefix) + "-global-isel=" +
704+
(A->getOption().matches(options::OPT_fglobal_isel) ? "1" : "0")));
705+
}
706+
697707
// If an explicit debugger tuning argument appeared, pass it along.
698708
if (Arg *A =
699709
Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) {

clang/test/Driver/lto.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,12 @@
105105
// FLTO-THIN: -flto=thin
106106
// FLTO-THIN-NOT: "-flto"
107107
// FLTO-THIN-NOT: -flto=full
108+
109+
// -flto passes along an explicit GlobalISel flag.
110+
// RUN: %clang --target=riscv64-linux-gnu -### %s -flto -fglobal-isel 2> %t
111+
// RUN: FileCheck --check-prefix=CHECK-GISEL < %t %s
112+
// RUN: %clang --target=aarch64-linux-gnu -### %s -flto -fno-global-isel 2> %t
113+
// RUN: FileCheck --check-prefix=CHECK-DISABLE-GISEL < %t %s
114+
//
115+
// CHECK-GISEL: "-plugin-opt=-global-isel=1"
116+
// CHECK-DISABLE-GISEL: "-plugin-opt=-global-isel=0"

0 commit comments

Comments
 (0)