]> granicus.if.org Git - clang/commitdiff
[MachineOutliner] Make -mno-outline use -enable-machine-outliner=never
authorJessica Paquette <jpaquette@apple.com>
Fri, 29 Jun 2018 18:06:10 +0000 (18:06 +0000)
committerJessica Paquette <jpaquette@apple.com>
Fri, 29 Jun 2018 18:06:10 +0000 (18:06 +0000)
This updates -mno-outline so that it passes -enable-machine-outliner=never
instead of nothing. This puts it in sync with the behaviour in llc and
other tools.

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

lib/Driver/ToolChains/Clang.cpp
test/Driver/aarch64-outliner.c

index 790fae4a6c8dee4a9617f417647ab35f808cfe40..5999d0b3f95447ac8b7d102244abc7bcbddb0eb1 100644 (file)
@@ -4797,23 +4797,30 @@ 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()) {
+  if (Arg *A = Args.getLastArg(options::OPT_moutline,
+                               options::OPT_mno_outline)) {
+    if (A->getOption().matches(options::OPT_moutline)) {
+      // 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-linkonceodr-outlining");
+        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");
+        }
       }
+    } else {
+      // Disable all outlining behaviour.
+      CmdArgs.push_back("-mllvm");
+      CmdArgs.push_back("-enable-machine-outliner=never");
     }
   }
 
index a02722df215a74d29841f7d9ce22b734fe107471..82f02ff99ff41ecbf21a879856b8822dc05ae6bd 100644 (file)
@@ -2,7 +2,7 @@
 // RUN: %clang -target aarch64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang -target aarch64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
-// OFF-NOT: "-mllvm" "-enable-machine-outliner"
+// OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang -target aarch64 -moutline -flto=thin -S %s -### 2>&1 | FileCheck %s -check-prefix=FLTO
 // FLTO: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: %clang -target aarch64 -moutline -flto=full -S %s -### 2>&1 | FileCheck %s -check-prefix=TLTO