diff options
author | Alon Zakai <azakai@google.com> | 2022-07-25 14:28:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 21:28:20 +0000 |
commit | 7c2b3ebd518b26c01fda9db8cb2a1911c23bed2a (patch) | |
tree | 7b019f1e71e28f2f0996a8a6f42d9f10e0ee1e51 /src | |
parent | 7fe3b11fc8309fbca27ef148069bdcbe5e68bbd4 (diff) | |
download | binaryen-7c2b3ebd518b26c01fda9db8cb2a1911c23bed2a.tar.gz binaryen-7c2b3ebd518b26c01fda9db8cb2a1911c23bed2a.tar.bz2 binaryen-7c2b3ebd518b26c01fda9db8cb2a1911c23bed2a.zip |
[Effects] call_ref traps when the target is null (#4826)
This is not observable in practice atm since call_ref also does a call,
which has even more effects. However, future optimizations might benefit
from this, and it is more consistent to avoid marking the instruction as
trapping if it can't.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/effects.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index e3f4b565d..8d643ffe3 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -667,12 +667,14 @@ private: if (curr->isReturn) { parent.branchesOut = true; } - // traps when the arg is null - parent.implicitTrap = true; + // traps when the call target is null + if (curr->target->type.isNullable()) { + parent.implicitTrap = true; + } } void visitRefTest(RefTest* curr) {} void visitRefCast(RefCast* curr) { - // Traps if the ref is not null and it has an invalid rtt. + // Traps if the ref is not null and the cast fails. parent.implicitTrap = true; } void visitBrOn(BrOn* curr) { parent.breakTargets.insert(curr->name); } |