-
Notifications
You must be signed in to change notification settings - Fork 830
Fix conflicting generalized types in TypeSSA #8119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+76
−79
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d2bc904
[NFC] Make fields of BrandTypeIterator constexpr
tlively 027025b
Fix conflicting generalized types in TypeSSA
tlively a0d970c
Merge branch 'main' into type-uniquer
tlively c1aa2ae
[NFC] Remove unused additionalPrivateTypes
tlively aac8e9b
Merge branch 'refactor-extra-private-types' into type-uniquer
tlively 27c8b51
address comments and fix GlobalTypeRewriter
tlively 8360a65
Merge branch 'main' into type-uniquer
tlively 811d645
Avoid public type collisions in GlobalTypeRewriter
tlively 37e043f
Merge branch 'type-updater-public-conflict' into type-uniquer
tlively 739d181
Merge branch 'main' into type-uniquer
tlively cc598a8
Reject rec groups that will collide after writing
tlively 5bdfdaf
newlines
tlively 34a4903
fix writeHeapType and add test
tlively 0671923
remove redundant move of const reference
tlively f7131c6
address comments
tlively d93e394
Merge branch 'validate-type-def-features' into type-uniquer
tlively bffc1e1
Merge branch 'main' into validate-type-def-features
tlively 09e166c
Merge branch 'validate-type-def-features' into type-uniquer
tlively d4f24a5
Merge branch 'main' into type-uniquer
tlively File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ | |
| ;; CHECK: (rec | ||
| ;; CHECK-NEXT: (type $A_1 (sub $A (shared (array (mut i32))))) | ||
|
|
||
| ;; CHECK: (type $4 (struct (field (mut i32)) (field (mut i32)) (field (mut f64)) (field (mut f64)) (field (mut i32)) (field (mut f64)) (field (mut f64)) (field (mut i32)) (field (mut i32)) (field (mut i32)) (field (mut i32)))) | ||
| ;; CHECK: (type $4 (struct)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TypeSSA no longer encodes a hash as a brand type, but rather uses the brand iterator, which produces much smaller types. |
||
|
|
||
| ;; CHECK: (func $func (type $1) | ||
| ;; CHECK-NEXT: (local $local (ref $B)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
| ;; RUN: wasm-opt %s -all --disable-custom-descriptors \ | ||
| ;; RUN: --type-ssa --roundtrip --fuzz-exec -S -o - | filecheck %s | ||
|
|
||
| (module | ||
| ;; CHECK: (type $foo (struct)) | ||
| (type $foo (struct)) | ||
| ;; CHECK: (type $super (sub (struct (field (ref $foo))))) | ||
| (type $super (sub (struct (field (ref $foo))))) | ||
| ;; CHECK: (type $sub (sub $super (struct (field (ref $foo))))) | ||
| (type $sub (sub $super (struct (field (ref (exact $foo)))))) | ||
|
|
||
| ;; CHECK: (type $3 (func (result i32))) | ||
|
|
||
| ;; CHECK: (rec | ||
| ;; CHECK-NEXT: (type $super_1 (sub $super (struct (field (ref $foo))))) | ||
|
|
||
| ;; CHECK: (type $5 (struct)) | ||
|
|
||
| ;; CHECK: (export "test" (func $test)) | ||
|
|
||
| ;; CHECK: (func $test (type $3) (result i32) | ||
| ;; CHECK-NEXT: (local $sub (ref $sub)) | ||
| ;; CHECK-NEXT: (local $any anyref) | ||
| ;; CHECK-NEXT: (ref.test (ref $sub) | ||
| ;; CHECK-NEXT: (select (result anyref) | ||
| ;; CHECK-NEXT: (struct.new $super_1 | ||
| ;; CHECK-NEXT: (struct.new_default $foo) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (local.get $any) | ||
| ;; CHECK-NEXT: (i32.const 1) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $test (export "test") (result i32) | ||
| (local $sub (ref $sub)) | ||
| (local $any anyref) | ||
| ;; TypeSSA will create another subtype of $super, which will differ from | ||
| ;; $sub because its field will not be exact. However, since exactness will | ||
| ;; be erased by the round trip, we still need a brand type to distinguish | ||
| ;; $sub and the new subtype. If we did not insert a brand type, this | ||
| ;; ref.test would incorrectly return 1 after optimization. | ||
| (ref.test (ref $sub) | ||
| ;; The select stops the ref.test from being optimized by finalization. | ||
| (select (result anyref) | ||
| (struct.new $super | ||
| (struct.new $foo) | ||
| ) | ||
| (local.get $any) | ||
| (i32.const 1) | ||
| ) | ||
| ) | ||
| ) | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fuzzer found a way to make this fail after about 80k iterations, so I'll investigate and fix that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can still happen when custom descriptors are disabled and the input already includes rec groups that differ only in exactness. This is nonsensical, but our validator doesn't reject it, so the fuzzer can still generate it. I'll investigate rejecting these cases in the parsers.