From 1610e6b3f5148d47c4f352c528db7d24bcfa598c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 8 Aug 2022 11:39:00 -0700 Subject: [Wasm GC] Fix SignaturePruning on CallWithoutEffects (#4882) call.without.effects will turn into a normal call of the last parameter later, (call $call.without.effects A B (ref.func $foo) ) ;; => intrinsic lowering (call $foo A B ) SignaturePruning needs to be aware of that: we can't remove a parameter from $foo without also updating relevant calls to $call.without.effects. Rather than handle that, just skip such cases, and leave them to be optimized after intrinsics are lowered away. --- src/passes/SignaturePruning.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/passes/SignaturePruning.cpp b/src/passes/SignaturePruning.cpp index ecf6d7e21..ca7bd0548 100644 --- a/src/passes/SignaturePruning.cpp +++ b/src/passes/SignaturePruning.cpp @@ -28,6 +28,7 @@ // #include "ir/find_all.h" +#include "ir/intrinsics.h" #include "ir/lubs.h" #include "ir/module-utils.h" #include "ir/type-updating.h" @@ -103,6 +104,18 @@ struct SignaturePruning : public Pass { // called. for (auto* call : info.calls) { allInfo[module->getFunction(call->target)->type].calls.push_back(call); + + // Intrinsics limit our ability to optimize in some cases. We will avoid + // modifying any type that is used by call.without.effects, to avoid + // the complexity of handling that. After intrinsics are lowered, + // this optimization will be able to run at full power anyhow. + if (Intrinsics(*module).isCallWithoutEffects(call)) { + // The last operand is the actual call target. + auto* target = call->operands.back(); + if (target->type != Type::unreachable) { + allInfo[target->type.getHeapType()].optimizable = false; + } + } } // For indirect calls, add each call_ref to the type the call_ref uses. -- cgit v1.2.3