]> granicus.if.org Git - clang/commitdiff
Make -mno-outline pass -enable-machine-outliner=never to ld in LTO
authorJessica Paquette <jpaquette@apple.com>
Tue, 26 Mar 2019 21:22:42 +0000 (21:22 +0000)
committerJessica Paquette <jpaquette@apple.com>
Tue, 26 Mar 2019 21:22:42 +0000 (21:22 +0000)
Since AArch64 has default outlining behaviour, we need to make sure that
-mno-outline is actually passed along to the linker in this case. Otherwise,
it will run by default on minsize functions even when -mno-outline is specified.

Also fix the darwin-ld test for this, which wasn't actually doing anything.

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

lib/Driver/ToolChains/Darwin.cpp
test/Driver/darwin-ld.c

index f91ab1946f51645d081db300f3fa3b78f66dac44..e113f9a679e1b73b73cd47547e4568e06441951b 100644 (file)
@@ -494,14 +494,23 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   // Propagate the -moutline flag to the linker in LTO.
-  if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) {
-    if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
-      CmdArgs.push_back("-mllvm");
-      CmdArgs.push_back("-enable-machine-outliner");
+  if (Arg *A =
+          Args.getLastArg(options::OPT_moutline, options::OPT_mno_outline)) {
+    if (A->getOption().matches(options::OPT_moutline)) {
+      if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
+        CmdArgs.push_back("-mllvm");
+        CmdArgs.push_back("-enable-machine-outliner");
 
-      // Outline from linkonceodr functions by default in LTO.
+        // Outline from linkonceodr functions by default in LTO.
+        CmdArgs.push_back("-mllvm");
+        CmdArgs.push_back("-enable-linkonceodr-outlining");
+      }
+    } else {
+      // Disable all outlining behaviour if we have mno-outline. We need to do
+      // this explicitly, because targets which support default outlining will
+      // try to do work if we don't.
       CmdArgs.push_back("-mllvm");
-      CmdArgs.push_back("-enable-linkonceodr-outlining");
+      CmdArgs.push_back("-enable-machine-outliner=never");
     }
   }
 
index b120bbe8a34a422eb46f1431dfde8a4c68436ac8..6886fbad2540982a9e4d5f3170bdf3cfdd08f11d 100644 (file)
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// MOUTLINE: ld
+// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
+// MOUTLINE: {{ld(.exe)?"}}
 // MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=MNO_OUTLINE %s < %t.log
+// MNO_OUTLINE: {{ld(.exe)?"}}
+// MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never"