Skip to content

Commit

Permalink
[lld] Add --lto-debug-pass-manager option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ellishg committed May 31, 2023
1 parent 1cf5188 commit f924104
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lld/MachO/Config.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lld/MachO/Driver.cpp
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions lld/MachO/LTO.cpp
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions lld/MachO/Options.td
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions 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
}

0 comments on commit f924104

Please sign in to comment.