From c25f32dec81d9401efb64cf134aa87991ef21e9d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Oct 2022 12:15:46 -0700 Subject: [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. --- src/passes/OptimizeInstructions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/passes/OptimizeInstructions.cpp') 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. -- cgit v1.2.3