[clang] 7b27167 - [Driver] Make "-fno-split-machine-functions" a valid flag for all archs
Han Shen via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 24 15:55:56 PDT 2023
Author: Han Shen
Date: 2023-08-24T15:55:43-07:00
New Revision: 7b27167a57c5809e9936fe3c0920054009cb46f4
URL: https://github.com/llvm/llvm-project/commit/7b27167a57c5809e9936fe3c0920054009cb46f4
DIFF: https://github.com/llvm/llvm-project/commit/7b27167a57c5809e9936fe3c0920054009cb46f4.diff
LOG: [Driver] Make "-fno-split-machine-functions" a valid flag for all archs
Previously, clang reports an error when -fno-split-machine-functions
is used for non-X86 archs.
However, in some cases, users may specify flags as
"-fsplit-machine-functions -fother-flags
-fno-split-machine-functions", the first one is from a global flag
set, the last one is used to negate the global flag, we think this is
a valid usage mode.
Another cases is when clang is used to invoke multiple workloads, like
"-x cuda -fsplit-machine-functions -Xarch_device
-fno-split-machine-functions", the latter is used to negate
-fsplit-machine-functions when invoke workloads for GPU."
This change makes this work.
Reviewed By: maskray
Differential Revision: https://reviews.llvm.org/D158755
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fsplit-machine-functions.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 39bc21b9678ba5..aaff62e5661a95 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,13 +5872,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
- // This codegen pass is only available on x86-elf targets.
- if (Triple.isX86() && Triple.isOSBinFormatELF()) {
- if (A->getOption().matches(options::OPT_fsplit_machine_functions))
+ if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
+ // This codegen pass is only available on x86-elf targets.
+ if (Triple.isX86() && Triple.isOSBinFormatELF())
A->render(Args, CmdArgs);
- } else {
- D.Diag(diag::err_drv_unsupported_opt_for_target)
- << A->getAsString(Args) << TripleStr;
+ else
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getAsString(Args) << TripleStr;
}
}
diff --git a/clang/test/Driver/fsplit-machine-functions.c b/clang/test/Driver/fsplit-machine-functions.c
index f77118a440e317..abd722c0e2392b 100644
--- a/clang/test/Driver/fsplit-machine-functions.c
+++ b/clang/test/Driver/fsplit-machine-functions.c
@@ -15,6 +15,4 @@
// RUN: not %clang -### -c --target=arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefix=ERR
// ERR: error: unsupported option '-fsplit-machine-functions' for target
-/// FIXME
-// RUN: not %clang -### -c --target=arm-unknown-linux -fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s --check-prefix=ERR2
-// ERR2: error: unsupported option '-fno-split-machine-functions' for target
+// RUN: %clang -### --target=arm-unknown-linux -fsplit-machine-functions -fno-split-machine-functions %s
More information about the cfe-commits
mailing list