summaryrefslogtreecommitdiffstats
path: root/lib/Driver/ToolChains/Darwin.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-07-06 22:24:56 +0000
committerJessica Paquette <jpaquette@apple.com>2018-07-06 22:24:56 +0000
commitf3ac792d41b6b98ea71ee4b433dcee005be7922e (patch)
tree8faa3a59a8c607ff356005b80677fc21ab0b3b75 /lib/Driver/ToolChains/Darwin.cpp
parent4ad65cd262150f7e5930824cc68afb528cff515f (diff)
[MachineOutliner] Properly pass -moutline along to the toolchain
This moves the LTO-specific code for outlining from ToolChains/Clang.cpp to ToolChains/Darwin.cpp. Passing -mllvm flags isn't sufficient for making sure that the specified pass will actually run in LTO. This makes sure that when -moutline is passed, the MachineOutliner will actually be added to the LTO pass pipeline as expected. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r--lib/Driver/ToolChains/Darwin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp
index 11f77096ae..9205dd52de 100644
--- a/lib/Driver/ToolChains/Darwin.cpp
+++ b/lib/Driver/ToolChains/Darwin.cpp
@@ -479,6 +479,18 @@ 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");
+
+ // Outline from linkonceodr functions by default in LTO.
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-enable-linkonceodr-outlining");
+ }
+ }
+
// It seems that the 'e' option is completely ignored for dynamic executables
// (the default), and with static executables, the last one wins, as expected.
Args.AddAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, options::OPT_t,