diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -205,6 +205,7 @@ // so use a vector instead of a map. std::vector sectionAlignments; std::vector segmentProtections; + bool ltoDebugPassManager = false; bool callGraphProfileSort = false; llvm::StringRef printSymbolOrder; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1636,6 +1636,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( diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp --- a/lld/MachO/LTO.cpp +++ b/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) diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td --- a/lld/MachO/Options.td +++ b/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; +def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">, + HelpText<"Debug new pass manager">, Group; // 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 --- /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 +}