]> granicus.if.org Git - clang/commitdiff
Enabling new pass manager in LTO (and thinLTO) link step.
authorSean Fertile <sfertile@ca.ibm.com>
Thu, 5 Oct 2017 01:50:48 +0000 (01:50 +0000)
committerSean Fertile <sfertile@ca.ibm.com>
Thu, 5 Oct 2017 01:50:48 +0000 (01:50 +0000)
Passes 'new-pass-manager' option to the linker plugin when the new pass
manager is enabled.

Patch by Graham Yiu.

Differential Revision: https://reviews.llvm.org/D38517

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314964 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/CommonArgs.cpp
test/Driver/gold-lto-new-pass-man.c [new file with mode: 0644]

index d052bb2001c2b64eaa830ff38f834b083aeac0f9..4020059f55a37714cfde7532cf7729357a972f98 100644 (file)
@@ -454,6 +454,14 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
       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,
diff --git a/test/Driver/gold-lto-new-pass-man.c b/test/Driver/gold-lto-new-pass-man.c
new file mode 100644 (file)
index 0000000..c2add0c
--- /dev/null
@@ -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"