diff options
author | Alon Zakai <azakai@google.com> | 2022-10-21 12:15:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 12:15:46 -0700 |
commit | c25f32dec81d9401efb64cf134aa87991ef21e9d (patch) | |
tree | cc8b2f5d244561663b4f908cad9eb3c5ae281202 /src/passes/OptimizeInstructions.cpp | |
parent | 884fe9bcee0a7aa10a427d76bd317bb136258dc6 (diff) | |
download | binaryen-c25f32dec81d9401efb64cf134aa87991ef21e9d.tar.gz binaryen-c25f32dec81d9401efb64cf134aa87991ef21e9d.tar.bz2 binaryen-c25f32dec81d9401efb64cf134aa87991ef21e9d.zip |
[Wasm GC] Externalize/Internalize allow nulls (#5175)
These are encoded as RefAs operations, and we have optimizations that assume those
trap on null, but Externalize/Internalize do not. Skip them there to avoid an error on the
type being incorrect later.
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 059ef28fb..3de7b6519 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -2040,6 +2040,12 @@ struct OptimizeInstructions return; } + if (curr->op == ExternExternalize || curr->op == ExternInternalize) { + // We can't optimize these. Even removing a non-null cast is not valid as + // they allow nulls to filter through, unlike other RefAs* + return; + } + skipNonNullCast(curr->value); // Check if the type is the kind we are checking for. |