[PATCH] D92917: [Driver] Pass -plugin-opt=no-new-pass-manager to the linker

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 8 23:20:09 PST 2020


MaskRay created this revision.
MaskRay added reviewers: aeubanks, asbirlea, ychen.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

So that if -fno-new-pass-manager is requested for an
-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=on build, ld.bfd/gold/ld.lld can know to
use the legacy PM.

Actually we only need to pass an option when the specified option is different
from the configured default, but that is difficult to test.  So we conditionally
pass a linker option.

Depends on D92916 <https://reviews.llvm.org/D92916>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92917

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/fnew-pass-manager.c


Index: clang/test/Driver/fnew-pass-manager.c
===================================================================
--- clang/test/Driver/fnew-pass-manager.c
+++ clang/test/Driver/fnew-pass-manager.c
@@ -19,7 +19,7 @@
 
 // NEW_LINK:    "-plugin-opt=new-pass-manager"
 
-/// TODO Add the negative option and pass it to the linker.
-// RUN: %clang -### -target x86_64 -flto -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=LEGACY_LINK %s
+// RUN: %clang -### -target x86_64-linux -flto -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=LEGACY_LINK %s
+// RUN: %clang -### -target x86_64-linux -flto=thin -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=LEGACY_LINK %s
 
-// LEGACY_LINK-NOT: "-plugin-opt=new-pass-manager"
+// LEGACY_LINK: "-plugin-opt=no-new-pass-manager"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -595,12 +595,13 @@
                                          Path));
   }
 
-  // Need this flag to turn on new pass manager via Gold plugin.
+  // Pass an option to enable/disable the new pass manager.
   if (Args.hasFlag(options::OPT_fnew_pass_manager,
                    options::OPT_fno_new_pass_manager,
-                   /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
+                   LLVM_ENABLE_NEW_PASS_MANAGER))
     CmdArgs.push_back("-plugin-opt=new-pass-manager");
-  }
+  else
+    CmdArgs.push_back("-plugin-opt=no-new-pass-manager");
 
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92917.310426.patch
Type: text/x-patch
Size: 1694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201209/4b4a3a4c/attachment-0001.bin>


More information about the cfe-commits mailing list