summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-10-21 01:49:14 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-10-21 01:49:14 +0000
commitde9cab942bf1f91643c2a88d95d9d6a55fc1e77f (patch)
tree81b78b2c30b4d0258d7fb62754235579cb1b1101 /clang/lib
parented84df008f609f7245871a9b6d00b57cb19410aa (diff)
downloadbcm5719-llvm-de9cab942bf1f91643c2a88d95d9d6a55fc1e77f.tar.gz
bcm5719-llvm-de9cab942bf1f91643c2a88d95d9d6a55fc1e77f.zip
[Driver][Darwin] Pass -no_deduplicate to ld64
Recent versions of ld64 run a deduplicate pass, which is on by default. Disable the pass by using -no_deduplicate in certain condition and enhance total compile time. rdar://problem/25455336 llvm-svn: 284798
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Tools.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index e6bfae68eec..2467758a56f 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -7882,6 +7882,29 @@ bool darwin::Linker::NeedsTempPath(const InputInfoList &Inputs) const {
return false;
}
+/// \brief Pass -no_deduplicate to ld64 under certain conditions:
+///
+/// - Either -O0 or -O1 is explicitly specified
+/// - No -O option is specified *and* this is a compile+link (implicit -O0)
+///
+/// Also do *not* add -no_deduplicate when no -O option is specified and this
+/// is just a link (we can't imply -O0)
+static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, const ArgList &Args) {
+ if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+ if (A->getOption().matches(options::OPT_O0))
+ return true;
+ if (A->getOption().matches(options::OPT_O))
+ return llvm::StringSwitch<bool>(A->getValue())
+ .Case("1", true)
+ .Default(false);
+ return false; // OPT_Ofast & OPT_O4
+ }
+
+ if (!IsLinkerOnlyAction) // Implicit -O0 for compile+linker only.
+ return true;
+ return false;
+}
+
void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
ArgStringList &CmdArgs,
const InputInfoList &Inputs) const {
@@ -7938,6 +7961,10 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
}
}
+ // ld64 version 262 and above run the deduplicate pass by default.
+ if (Version[0] >= 262 && shouldLinkerNotDedup(C.getJobs().empty(), Args))
+ CmdArgs.push_back("-no_deduplicate");
+
// Derived from the "link" spec.
Args.AddAllArgs(CmdArgs, options::OPT_static);
if (!Args.hasArg(options::OPT_static))
OpenPOWER on IntegriCloud