[PATCH] D38517: Enabling new pass manager in LTO (and thinLTO) link step via -fexperimental-new-pass-manager option
Graham Yiu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 08:52:57 PDT 2017
gyiu updated this revision to Diff 117677.
gyiu added a comment.
Add new testcase to make sure plugin-opt is passed to gold linker to enable new pass manager.
Repository:
rL LLVM
https://reviews.llvm.org/D38517
Files:
lib/Driver/ToolChains/CommonArgs.cpp
test/Driver/gold-lto-new-pass-man.c
tools/gold/gold-plugin.cpp
Index: test/Driver/gold-lto-new-pass-man.c
===================================================================
--- /dev/null
+++ test/Driver/gold-lto-new-pass-man.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target ppc64le-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fexperimental-new-pass-manager \
+// RUN: | FileCheck %s
+// CHECK: "-plugin-opt=new-pass-manager"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -454,6 +454,14 @@
CmdArgs.push_back(
Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName));
}
+
+ // Need this flag to turn on new pass manager via Gold plugin.
+ if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager,
+ options::OPT_fno_experimental_new_pass_manager,
+ /* Default */ false)) {
+ CmdArgs.push_back("-plugin-opt=new-pass-manager");
+ }
+
}
void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -183,6 +183,8 @@
static std::vector<const char *> extra;
// Sample profile file path
static std::string sample_profile;
+ // New pass manager
+ static bool new_pass_manager = false;
static void process_plugin_option(const char *opt_)
{
@@ -242,6 +244,8 @@
DisableVerify = true;
} else if (opt.startswith("sample-profile=")) {
sample_profile= opt.substr(strlen("sample-profile="));
+ } else if (opt == "new-pass-manager") {
+ new_pass_manager = true;
} else {
// Save this option to pass to the code generator.
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -810,6 +814,9 @@
if (!options::sample_profile.empty())
Conf.SampleProfile = options::sample_profile;
+ // Use new pass manager if set in driver
+ Conf.UseNewPM = options::new_pass_manager;
+
return llvm::make_unique<LTO>(std::move(Conf), Backend,
options::ParallelCodeGenParallelismLevel);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38517.117677.patch
Type: text/x-patch
Size: 2301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/191b8d9c/attachment.bin>
More information about the llvm-commits
mailing list