r336001 - [MachineOutliner] Make -mno-outline use -enable-machine-outliner=never

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 29 11:06:10 PDT 2018


Author: paquette
Date: Fri Jun 29 11:06:10 2018
New Revision: 336001

URL: http://llvm.org/viewvc/llvm-project?rev=336001&view=rev
Log:
[MachineOutliner] Make -mno-outline use -enable-machine-outliner=never

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.

Modified:
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/test/Driver/aarch64-outliner.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=336001&r1=336000&r2=336001&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jun 29 11:06:10 2018
@@ -4797,23 +4797,30 @@ 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()) {
+  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");
     }
   }
 

Modified: cfe/trunk/test/Driver/aarch64-outliner.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-outliner.c?rev=336001&r1=336000&r2=336001&view=diff
==============================================================================
--- cfe/trunk/test/Driver/aarch64-outliner.c (original)
+++ cfe/trunk/test/Driver/aarch64-outliner.c Fri Jun 29 11:06:10 2018
@@ -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




More information about the cfe-commits mailing list