]> granicus.if.org Git - clang/commitdiff
[MachineOutliner] Emit a warning when using -moutline on unsupported targets
authorJessica Paquette <jpaquette@apple.com>
Tue, 26 Jun 2018 22:09:48 +0000 (22:09 +0000)
committerJessica Paquette <jpaquette@apple.com>
Tue, 26 Jun 2018 22:09:48 +0000 (22:09 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335672 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ef7b0db89f876b07647252514bbfb02fd0ed52e6..5526ad4bd5cd690e174b60bf39116eeddaafedde 100644 (file)
@@ -385,4 +385,8 @@ def warn_drv_experimental_isel_incomplete : Warning<
 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>;
 }
index 327fa6b57b5cc9da9684734f95a085fdd920dda2..1f08f303452118c49e7e57b3cb0431a94d381443 100644 (file)
@@ -1476,19 +1476,6 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
     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, const JobAction &JA,
                    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 &&
index dd2ae2a66c75c20ead635267b1241fbf2432ea24..a02722df215a74d29841f7d9ce22b734fe107471 100644 (file)
@@ -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"