summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-11-08 16:23:09 -0800
committerGitHub <noreply@github.com>2021-11-09 00:23:09 +0000
commited4d22e22414a561e5b5af0064a3a47fc8db1645 (patch)
tree9c870d4aad45345773936fb61270f19889b539da /src
parentb604ad935d1adc8498872e8afdb18df2f9b3b572 (diff)
downloadbinaryen-ed4d22e22414a561e5b5af0064a3a47fc8db1645.tar.gz
binaryen-ed4d22e22414a561e5b5af0064a3a47fc8db1645.tar.bz2
binaryen-ed4d22e22414a561e5b5af0064a3a47fc8db1645.zip
Effects.h: Fix RefAs (#4312)
We marked that as only trapping if the input as nullable. But ref.as_func will trap if it isn't a func, for example. We could in theory try to check if a trap is possible, like checking if the input is already non-nullable or already a function, etc., but we have optimization passes to get rid of RefAs when they are not needed anyhow, so there is no point to duplicate that here.
Diffstat (limited to 'src')
-rw-r--r--src/ir/effects.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h
index f24f0ac3f..ced8e63cb 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -725,9 +725,15 @@ private:
}
void visitRefAs(RefAs* curr) {
// traps when the arg is not valid
- if (curr->value->type.isNullable()) {
- parent.implicitTrap = true;
- }
+ parent.implicitTrap = true;
+ // Note: We could be more precise here and report the lack of a possible
+ // trap if the input is non-nullable (and also of the right kind for
+ // RefAsFunc etc.). However, we have optimization passes that will
+ // remove a RefAs in such a case (in OptimizeInstructions, and also
+ // Vacuum in trapsNeverHappen mode), so duplicating that code here would
+ // only help until the next time those optimizations run. As a tradeoff,
+ // we keep the code here simpler, but it does mean another optimization
+ // cycle may be needed in some cases.
}
};