diff options
author | Alon Zakai <azakai@google.com> | 2023-10-16 15:51:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 15:51:05 -0700 |
commit | 2d1e1501f5da1436f61c8ff5440aca33e25a29e9 (patch) | |
tree | c75bd423561c1d33a59279cb45d5c5298d4ed954 /src | |
parent | f686b6887439f81a99599b0667e02c8d1f698935 (diff) | |
download | binaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.tar.gz binaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.tar.bz2 binaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.zip |
Heap2Local: Refinalize when removing a cast (#6012)
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Heap2Local.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/passes/Heap2Local.cpp b/src/passes/Heap2Local.cpp index e027f5a46..f0f691299 100644 --- a/src/passes/Heap2Local.cpp +++ b/src/passes/Heap2Local.cpp @@ -440,6 +440,20 @@ struct Heap2LocalOptimizer { // the allocation is a subtype of the type of the cast, and so // cannot trap. replaceCurrent(curr->ref); + + // We need to refinalize after this, as while we know the cast is not + // logically needed - the value flowing through will not be used - we do + // need validation to succeed even before other optimizations remove the + // code. For example: + // + // (block (result $B) + // (ref.cast $B + // (block (result $A) + // + // Without the cast this does not validate, so we need to refinalize + // (which will fix this, as we replace the unused value with a null, so + // that type will propagate out). + refinalize = true; } void visitStructSet(StructSet* curr) { |