From: Sean Fertile Date: Thu, 5 Oct 2017 01:50:48 +0000 (+0000) Subject: Enabling new pass manager in LTO (and thinLTO) link step. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2787a6b9332ec828889a6aa1de4d7738524110a;p=clang Enabling new pass manager in LTO (and thinLTO) link step. 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 --- diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp index d052bb2001..4020059f55 100644 --- a/lib/Driver/ToolChains/CommonArgs.cpp +++ b/lib/Driver/ToolChains/CommonArgs.cpp @@ -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 index 0000000000..c2add0c73a --- /dev/null +++ b/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"