Author: Jon Roelofs
Date: 2023-08-14T16:22:48-07:00
New Revision: 1a135bceb66b2d448ba4363af2f8626b6e4110bd

URL: 
https://github.com/llvm/llvm-project/commit/1a135bceb66b2d448ba4363af2f8626b6e4110bd
DIFF: 
https://github.com/llvm/llvm-project/commit/1a135bceb66b2d448ba4363af2f8626b6e4110bd.diff

LOG: [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all 
targets.

... that have the outliner enabled.

Differential revision: https://reviews.llvm.org/D157925

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 239fbf21d77f5a..1b785eae42bc4b 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -615,10 +615,6 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
       if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
         CmdArgs.push_back("-mllvm");
         CmdArgs.push_back("-enable-machine-outliner");
-
-        // 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
@@ -629,6 +625,12 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
     }
   }
 
+  // Outline from linkonceodr functions by default in LTO, whenever the 
outliner
+  // is enabled.  Note that the target may enable the machine outliner
+  // independently of -moutline.
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-linkonceodr-outlining");
+
   // Setup statistics file output.
   SmallString<128> StatsFile =
       getStatsFileName(Args, Output, Inputs[0], getToolChain().getDriver());

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index b8d0a9a9b25af9..b835b1f876beb5 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // 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
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MOUTLINE %s < %t.log
+// ARM64E-MOUTLINE: {{ld(.exe)?"}}
+// ARM64E-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MOUTLINE %s < %t.log
+// ARMV7EM-MOUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MOUTLINE-SAME: "-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"
+// RUN: FileCheck -check-prefix=ARM64-MNO_OUTLINE %s < %t.log
+// ARM64-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MNO_OUTLINE %s < %t.log
+// ARM64E-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64E-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MNO_OUTLINE %s < %t.log
+// ARMV7EM-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"
\ No newline at end of file


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to