[lld] f924104 - [lld] Add --lto-debug-pass-manager option
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 14:14:28 PDT 2023
Author: Ellis Hoag
Date: 2023-05-31T14:14:19-07:00
New Revision: f92410429a2cbe4cec5a57a1fe7e43bc02b4d399
URL: https://github.com/llvm/llvm-project/commit/f92410429a2cbe4cec5a57a1fe7e43bc02b4d399
DIFF: https://github.com/llvm/llvm-project/commit/f92410429a2cbe4cec5a57a1fe7e43bc02b4d399.diff
LOG: [lld] Add --lto-debug-pass-manager option
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
Reviewed By: #lld-macho, MaskRay, int3
Differential Revision: https://reviews.llvm.org/D151746
Added:
lld/test/MachO/new-pass-manager.ll
Modified:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/LTO.cpp
lld/MachO/Options.td
Removed:
################################################################################
diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 762f5a1edd134..27586c8320c63 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -205,6 +205,7 @@ struct Configuration {
// 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;
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 687a8b7c6e18f..595a540a9cc11 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1636,6 +1636,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
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(
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index a2d3934c5bced..0e8e1056326f9 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -68,6 +68,7 @@ static lto::Config createConfig() {
c.TimeTraceEnabled = config->timeTraceEnabled;
c.TimeTraceGranularity = config->timeTraceGranularity;
+ c.DebugPassManager = config->ltoDebugPassManager;
c.OptLevel = config->ltoo;
c.CGOptLevel = config->ltoCgo;
if (config->saveTemps)
diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 9108d68205799..d564ebd34ef77 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -124,6 +124,8 @@ def strict_auto_link : Flag<["--"], "strict-auto-link">,
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
diff --git a/lld/test/MachO/new-pass-manager.ll b/lld/test/MachO/new-pass-manager.ll
new file mode 100644
index 0000000000000..4324ed85dc1d2
--- /dev/null
+++ b/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 @foo() {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list