r335672 - [MachineOutliner] Emit a warning when using -moutline on unsupported targets

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 26 15:09:48 PDT 2018


Author: paquette
Date: Tue Jun 26 15:09:48 2018
New Revision: 335672

URL: http://llvm.org/viewvc/llvm-project?rev=335672&view=rev
Log:
[MachineOutliner] Emit a warning when using -moutline on unsupported targets

Instead of just saying "flag unused", we should tell the user that the
outliner isn't (at least officially) supported for some given architecture.

This adds a warning that will state something like

The 'blah' architecture does not support -moutline; flag ignored

when we call -moutline with the 'blah' architecture.

Since the outliner is still mostly an AArch64 thing, any architecture
other than AArch64 will emit this warning.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/test/Driver/aarch64-outliner.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=335672&r1=335671&r2=335672&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jun 26 15:09:48 2018
@@ -385,4 +385,8 @@ def warn_drv_experimental_isel_incomplet
 def warn_drv_experimental_isel_incomplete_opt : Warning<
   "-fexperimental-isel support is incomplete for this architecture at the current optimization level">,
   InGroup<ExperimentalISel>;
+
+def warn_drv_moutline_unsupported_opt : Warning<
+  "The '%0' architecture does not support -moutline; flag ignored">,
+  InGroup<OptionIgnored>;
 }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=335672&r1=335671&r2=335672&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Jun 26 15:09:48 2018
@@ -1476,19 +1476,6 @@ void Clang::AddAArch64TargetArgs(const A
     else
       CmdArgs.push_back("-aarch64-enable-global-merge=true");
   }
-
-  if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) {
-    CmdArgs.push_back("-mllvm");
-    CmdArgs.push_back("-enable-machine-outliner");
-
-    // The outliner shouldn't compete with linkers that dedupe linkonceodr
-    // functions in LTO. Enable that behaviour by default when compiling with
-    // LTO.
-    if (getToolChain().getDriver().isUsingLTO()) {
-      CmdArgs.push_back("-mllvm");
-      CmdArgs.push_back("-enable-linkonceodr-outlining");
-    }
-  }
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,
@@ -4814,6 +4801,26 @@ void Clang::ConstructJob(Compilation &C,
                    options::OPT_fno_complete_member_pointers, false))
     CmdArgs.push_back("-fcomplete-member-pointers");
 
+  if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) {
+    // We only support -moutline in AArch64 right now. If we're not compiling
+    // for AArch64, emit a warning and ignore the flag. Otherwise, add the
+    // proper mllvm flags.
+    if (Triple.getArch() != llvm::Triple::aarch64) {
+      D.Diag(diag::warn_drv_moutline_unsupported_opt) << Triple.getArchName();
+    } else {
+      CmdArgs.push_back("-mllvm");
+      CmdArgs.push_back("-enable-machine-outliner");
+
+      // The outliner shouldn't compete with linkers that dedupe linkonceodr
+      // functions in LTO. Enable that behaviour by default when compiling with
+      // LTO.
+      if (getToolChain().getDriver().isUsingLTO()) {
+        CmdArgs.push_back("-mllvm");
+        CmdArgs.push_back("-enable-linkonceodr-outlining");
+      }
+    }
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
       Output.getType() == types::TY_Object &&

Modified: cfe/trunk/test/Driver/aarch64-outliner.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-outliner.c?rev=335672&r1=335671&r2=335672&view=diff
==============================================================================
--- cfe/trunk/test/Driver/aarch64-outliner.c (original)
+++ cfe/trunk/test/Driver/aarch64-outliner.c Tue Jun 26 15:09:48 2018
@@ -7,3 +7,6 @@
 // FLTO: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: %clang -target aarch64 -moutline -flto=full -S %s -### 2>&1 | FileCheck %s -check-prefix=TLTO
 // TLTO: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: %clang -target x86_64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=WARN
+// WARN: warning: The 'x86_64' architecture does not support -moutline; flag ignored [-Woption-ignored]
+// WARN-NOT: "-mllvm" "-enable-machine-outliner"




More information about the cfe-commits mailing list