[PATCH] D158755: Make "-fno-split-machine-functions" a valid flag for all archs.

Han Shen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 11:56:18 PDT 2023


shenhan updated this revision to Diff 553219.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158755/new/

https://reviews.llvm.org/D158755

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===================================================================
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -15,6 +15,10 @@
 // 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: not %clang -### -x cuda -S -nocudainc -nocudalib -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefix=ERR2
+// ERR2: clang: error: unsupported option '-fsplit-machine-functions' for target
+
+// The following all run successfully.
+// RUN: %clang -### -x cuda -S -nocudainc -nocudalib -fsplit-machine-functions -Xarch_device -fno-split-machine-functions %s
+// RUN: %clang -### -x cuda -S -nocudainc -nocudalib -Xarch_host -fsplit-machine-functions %s
+// RUN: %clang -### --target=arm-unknown-linux -fsplit-machine-functions -fno-split-machine-functions %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,13 +5872,13 @@
 
   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;
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158755.553219.patch
Type: text/x-patch
Size: 2310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230824/e26a1cc9/attachment.bin>


More information about the cfe-commits mailing list