From 0379e8b42daa116336f2688d02eeebed2240a99c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 21 Apr 2021 19:54:56 -0700 Subject: [Wasm GC] Skip DeadArgumentElimination of an RTT parameter (#3834) We could more carefully see when a local is not needed there, but atm we always add one, and that doesn't work for something nondefaultable. --- src/passes/DeadArgumentElimination.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp index 37aaace37..33ca81dc7 100644 --- a/src/passes/DeadArgumentElimination.cpp +++ b/src/passes/DeadArgumentElimination.cpp @@ -373,13 +373,19 @@ struct DAE : public Pass { // Great, it's not used. Check if none of the calls has a param with // side effects, as that would prevent us removing them (flattening // should have been done earlier). - bool canRemove = + bool callParamsAreValid = std::none_of(calls.begin(), calls.end(), [&](Call* call) { auto* operand = call->operands[i]; return EffectAnalyzer(runner->options, module->features, operand) .hasSideEffects(); }); - if (canRemove) { + // The type must be valid for us to handle as a local (since we + // replace the parameter with a local). + // TODO: if there are no references at all, we can avoid creating a + // local + bool typeIsValid = + TypeUpdating::canHandleAsLocal(func->getLocalType(i)); + if (callParamsAreValid && typeIsValid) { // Wonderful, nothing stands in our way! Do it. // TODO: parallelize this? removeParameter(func, i, calls); -- cgit v1.2.3