[llvm-branch-commits] [lld] 1314a49 - [LTO][wasm][NewPM] Allow using new pass manager for wasm LTO

Arthur Eubanks via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 1 12:30:43 PST 2020


Author: Arthur Eubanks
Date: 2020-12-01T12:22:40-08:00
New Revision: 1314a4938fba865412598b7227cb4657d59cd8bc

URL: https://github.com/llvm/llvm-project/commit/1314a4938fba865412598b7227cb4657d59cd8bc
DIFF: https://github.com/llvm/llvm-project/commit/1314a4938fba865412598b7227cb4657d59cd8bc.diff

LOG: [LTO][wasm][NewPM] Allow using new pass manager for wasm LTO

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D92150

Added: 
    lld/test/wasm/lto/new-pass-manager.ll

Modified: 
    lld/wasm/Config.h
    lld/wasm/Driver.cpp
    lld/wasm/LTO.cpp
    lld/wasm/Options.td

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/lto/new-pass-manager.ll b/lld/test/wasm/lto/new-pass-manager.ll
new file mode 100644
index 000000000000..2f49c4d55df8
--- /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
index 68b09a653d40..f18debfb1f83 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -62,6 +62,8 @@ struct Configuration {
   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
index f26b190b6058..d15cf40f6e5f 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -379,6 +379,9 @@ static void readConfigs(opt::InputArgList &args) {
   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, false);
+  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
index 28b62022f29f..4f76fc0dccdb 100644
--- a/lld/wasm/LTO.cpp
+++ b/lld/wasm/LTO.cpp
@@ -52,6 +52,8 @@ static std::unique_ptr<lto::LTO> createLTO() {
   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
index 620b3bd10550..283fe3fc2931 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -215,6 +215,12 @@ def thinlto_cache_dir: J<"thinlto-cache-dir=">,
 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">,


        


More information about the llvm-branch-commits mailing list