diff --git a/lld/test/wasm/lto/new-pass-manager.ll b/lld/test/wasm/lto/new-pass-manager.ll new file mode 100644 --- /dev/null +++ b/lld/test/wasm/lto/new-pass-manager.ll @@ -0,0 +1,15 @@ +; RUN: llvm-as -o %t.bc %s +; RUN: wasm-ld --lto-new-pass-manager --lto-debug-pass-manager -o /dev/null %t.bc 2>&1 | FileCheck %s +; RUN: wasm-ld --lto-new-pass-manager --lto-debug-pass-manager --lto-no-new-pass-manager -o /dev/null %t.bc 2>&1 | FileCheck %s --allow-empty --check-prefix=LPM + +; CHECK: Starting llvm::Module pass manager run +; CHECK: Finished llvm::Module pass manager run +; LPM-NOT: Starting llvm::Module pass manager run + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown" + +define void @_start() local_unnamed_addr { +entry: + ret void +} diff --git a/lld/wasm/Config.h b/lld/wasm/Config.h --- a/lld/wasm/Config.h +++ b/lld/wasm/Config.h @@ -62,6 +62,8 @@ unsigned ltoo; unsigned optimize; llvm::StringRef thinLTOJobs; + bool ltoNewPassManager; + bool ltoDebugPassManager; UnresolvedPolicy unresolvedSymbols; llvm::StringRef entry; diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -379,6 +379,9 @@ config->importTable = args.hasArg(OPT_import_table); config->ltoo = args::getInteger(args, OPT_lto_O, 2); config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1); + config->ltoNewPassManager = + args.hasFlag(OPT_lto_new_pass_manager, OPT_lto_no_new_pass_manager, true); + config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->mapFile = args.getLastArgValue(OPT_Map); config->optimize = args::getInteger(args, OPT_O, 0); config->outputFile = args.getLastArgValue(OPT_o); diff --git a/lld/wasm/LTO.cpp b/lld/wasm/LTO.cpp --- a/lld/wasm/LTO.cpp +++ b/lld/wasm/LTO.cpp @@ -52,6 +52,8 @@ c.OptLevel = config->ltoo; c.MAttrs = getMAttrs(); c.CGOptLevel = args::getCGOptLevel(config->ltoo); + c.UseNewPM = config->ltoNewPassManager; + c.DebugPassManager = config->ltoDebugPassManager; if (config->relocatable) c.RelocModel = None; diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td --- a/lld/wasm/Options.td +++ b/lld/wasm/Options.td @@ -215,6 +215,12 @@ defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">; def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs. Default to --threads=">; +def lto_new_pass_manager: F<"lto-new-pass-manager">, + HelpText<"Use new pass manager">; +def lto_no_new_pass_manager: F<"lto-no-new-pass-manager">, + HelpText<"Use legacy pass manager">; +def lto_debug_pass_manager: F<"lto-debug-pass-manager">, + HelpText<"Debug new pass manager">; // Experimental PIC mode. def experimental_pic: F<"experimental-pic">,