[PATCH] D151746: [lld] Add --lto-debug-pass-manager option

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 13:09:33 PDT 2023


ellis created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
ellis edited the summary of this revision.
ellis added reviewers: MaskRay, xur, int3.
ellis edited the summary of this revision.
ellis published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add support for printing the passes run for LTO.

Both ELF and COFF have `--lto-debug-pass-manager` (`-ltodebugpassmanager`) to print the compiler passes run during LTO. This is useful to check that a certain compiler pass is run in a test, e.g., https://reviews.llvm.org/D151589


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151746

Files:
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/LTO.cpp
  lld/MachO/Options.td
  lld/test/MachO/new-pass-manager.ll


Index: lld/test/MachO/new-pass-manager.ll
===================================================================
--- /dev/null
+++ lld/test/MachO/new-pass-manager.ll
@@ -0,0 +1,14 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib --lto-debug-pass-manager -o /dev/null %t.o 2>&1 | FileCheck %s
+
+; CHECK: Running pass: GlobalOptPass
+
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-darwin"
+
+define void @_start() {
+entry:
+  ret void
+}
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -124,6 +124,8 @@
 def check_category_conflicts : Flag<["--"], "check-category-conflicts">,
     HelpText<"Check for conflicts between category & class methods">,
     Group<grp_lld>;
+def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">,
+    HelpText<"Debug new pass manager">, Group<grp_lld>;
 
 // This is a complete Options.td compiled from Apple's ld(1) manpage
 // dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/LTO.cpp
===================================================================
--- lld/MachO/LTO.cpp
+++ lld/MachO/LTO.cpp
@@ -68,6 +68,7 @@
 
   c.TimeTraceEnabled = config->timeTraceEnabled;
   c.TimeTraceGranularity = config->timeTraceGranularity;
+  c.DebugPassManager = config->ltoDebugPassManager;
   c.OptLevel = config->ltoo;
   c.CGOptLevel = config->ltoCgo;
   if (config->saveTemps)
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1637,6 +1637,7 @@
   for (const Arg *arg : args.filtered(OPT_ignore_auto_link_option))
     config->ignoreAutoLinkOptions.insert(arg->getValue());
   config->strictAutoLink = args.hasArg(OPT_strict_auto_link);
+  config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
 
   for (const Arg *arg : args.filtered(OPT_alias)) {
     config->aliasedSymbols.push_back(
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -206,6 +206,7 @@
   // so use a vector instead of a map.
   std::vector<SectionAlign> sectionAlignments;
   std::vector<SegmentProtection> segmentProtections;
+  bool ltoDebugPassManager = false;
 
   bool callGraphProfileSort = false;
   llvm::StringRef printSymbolOrder;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151746.526750.patch
Type: text/x-patch
Size: 2485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230530/fc65c9ae/attachment.bin>


More information about the llvm-commits mailing list