diff options
author | Alon Zakai <azakai@google.com> | 2024-10-22 09:17:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 09:17:05 -0700 |
commit | 0d9b7508e5de1ca7befef493ed3e357b8a5613a1 (patch) | |
tree | c14721e0059d5c05ea3f2c80424b9fd3d3e7b92c /src | |
parent | bc36c02d1a54c91d9fc4bdbffe00608929ec3169 (diff) | |
download | binaryen-0d9b7508e5de1ca7befef493ed3e357b8a5613a1.tar.gz binaryen-0d9b7508e5de1ca7befef493ed3e357b8a5613a1.tar.bz2 binaryen-0d9b7508e5de1ca7befef493ed3e357b8a5613a1.zip |
[GC] Fix assertion in GlobalTypeOptimization about public super (#7026)
We only checked for the case of the immediate super being public while we
are private, but it might be a grandsuper instead. That is, any ancestor that
is public will prevent GTO from removing a field (since we can only add
fields on top of our ancestors). Also, the ancestors might not all have the
field, which would add more complexity to that particular assertion, so just
remove it, and add comprehensive tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/GlobalTypeOptimization.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/passes/GlobalTypeOptimization.cpp b/src/passes/GlobalTypeOptimization.cpp index 74107f9cd..e35e30ac8 100644 --- a/src/passes/GlobalTypeOptimization.cpp +++ b/src/passes/GlobalTypeOptimization.cpp @@ -311,15 +311,10 @@ struct GlobalTypeOptimization : public Pass { keptFieldsNotInSuper.push_back(i); } } else { - // The super kept this field, so we must keep it as well. The - // propagation analysis above ensures that we and the super are in - // agreement on keeping it (the reasons that prevent optimization - // propagate to both), except for the corner case of the parent - // being public but us being private (the propagation does not - // take into account visibility). - assert( - !removableIndexes.count(i) || - (publicTypesSet.count(*super) && !publicTypesSet.count(type))); + // The super kept this field, so we must keep it as well. This can + // happen when we need the field in both, but also in the corner + // case where we don't need the field but the super is public. + // We need to keep it at the same index so we remain compatible. indexesAfterRemoval[i] = superIndex; // Update |next| to refer to the next available index. Due to |