[PATCH] D38517: Enabling new pass manager in LTO (and thinLTO) link step via -fexperimental-new-pass-manager option

2017-10-03 Thread Graham Yiu via Phabricator via cfe-commits
gyiu created this revision.
Herald added subscribers: inglorion, mehdi_amini.

Modifications to driver and gold plugin code to get the new pass manager path 
enabled in LTO (and thinLTO).


Repository:
  rL LLVM

https://reviews.llvm.org/D38517

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  tools/gold/gold-plugin.cpp


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 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(std::move(Conf), Backend,
 options::ParallelCodeGenParallelismLevel);
 }


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 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(std::move(Conf), Backend,
 options::ParallelCodeGenParallelismLevel);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38517: Enabling new pass manager in LTO (and thinLTO) link step via -fexperimental-new-pass-manager option

2017-10-04 Thread Graham Yiu via Phabricator via cfe-commits
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 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(std::move(Conf), Backend,
 options::ParallelCodeGenParallelismLevel);
 }


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 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(std::move(Conf), Backend,
 options::ParallelCodeGenParallelismLevel);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org