From 11932cc31e88d3d368714fcca43df979f7694bd1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Mar 2022 16:33:53 -0700 Subject: [Wasm GC] Signature Pruning (#4545) This adds a new signature-pruning pass that prunes parameters from signature types where those parameters are never used in any function that has that type. This is similar to DeadArgumentElimination but works on a set of functions, and it can handle indirect calls. Also move a little code from SignatureRefining into a shared place to avoid duplication of logic to update signature types. This pattern happens in j2wasm code, for example if all method functions for some virtual method just return a constant and do not use the this pointer. --- src/passes/pass.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 3ac4485e3..04947ae07 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -353,6 +353,9 @@ void PassRegistry::registerPasses() { registerPass("set-globals", "sets specified globals to specified values", createSetGlobalsPass); + registerPass("signature-pruning", + "remove params from function signature types where possible", + createSignaturePruningPass); registerPass("signature-refining", "apply more specific subtypes to signature types where possible", createSignatureRefiningPass); @@ -549,6 +552,7 @@ void PassRunner::addDefaultGlobalOptimizationPrePasses() { if (wasm->features.hasGC() && getTypeSystem() == TypeSystem::Nominal && options.optimizeLevel >= 2) { addIfNoDWARFIssues("type-refining"); + addIfNoDWARFIssues("signature-pruning"); addIfNoDWARFIssues("signature-refining"); addIfNoDWARFIssues("global-refining"); // Global type optimization can remove fields that are not needed, which can -- cgit v1.2.3