summaryrefslogtreecommitdiff
path: root/src/ir/effects.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-07-25 14:28:20 -0700
committerGitHub <noreply@github.com>2022-07-25 21:28:20 +0000
commit7c2b3ebd518b26c01fda9db8cb2a1911c23bed2a (patch)
tree7b019f1e71e28f2f0996a8a6f42d9f10e0ee1e51 /src/ir/effects.h
parent7fe3b11fc8309fbca27ef148069bdcbe5e68bbd4 (diff)
downloadbinaryen-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/ir/effects.h')
-rw-r--r--src/ir/effects.h8
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); }