[PATCH] D116128: [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple

Nathan Chancellor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 23 11:49:32 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe8180af5854: [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64… (authored by nathanchance).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116128

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-outline-atomics.c


Index: clang/test/Driver/unsupported-outline-atomics.c
===================================================================
--- /dev/null
+++ clang/test/Driver/unsupported-outline-atomics.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-X86
+// CHECK-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-X86
+// CHECK-NO-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "-outline-atomics"
+
+// RUN: %clang -target riscv64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-RISCV
+// CHECK-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support '-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target riscv64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-RISCV
+// CHECK-NO-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support '-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "-outline-atomics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7007,18 +7007,18 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
                                options::OPT_mno_outline_atomics)) {
-    if (A->getOption().matches(options::OPT_moutline_atomics)) {
-      // Option -moutline-atomics supported for AArch64 target only.
-      if (!Triple.isAArch64()) {
-        D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-            << Triple.getArchName();
-      } else {
+    // Option -moutline-atomics supported for AArch64 target only.
+    if (!Triple.isAArch64()) {
+      D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+          << Triple.getArchName() << A->getOption().getName();
+    } else {
+      if (A->getOption().matches(options::OPT_moutline_atomics)) {
         CmdArgs.push_back("-target-feature");
         CmdArgs.push_back("+outline-atomics");
+      } else {
+        CmdArgs.push_back("-target-feature");
+        CmdArgs.push_back("-outline-atomics");
       }
-    } else {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-outline-atomics");
     }
   } else if (Triple.isAArch64() &&
              getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -568,7 +568,7 @@
   InGroup<OptionIgnored>;
 
 def warn_drv_moutline_atomics_unsupported_opt : Warning<
-  "'%0' does not support '-moutline-atomics'; flag ignored">,
+  "'%0' does not support '-%1'; flag ignored">,
   InGroup<OptionIgnored>;
 
 def warn_drv_darwin_sdk_invalid_settings : Warning<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116128.396066.patch
Type: text/x-patch
Size: 3424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211223/5e4aae2b/attachment.bin>


More information about the cfe-commits mailing list