-
Notifications
You must be signed in to change notification settings - Fork 832
Remove assertion about repeat types in TypeSSA #8176
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
+85
−2
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| ;; 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 --dae --type-ssa -S -o - | filecheck %s | ||
|
|
||
| (module | ||
| ;; CHECK: (type $struct (struct)) | ||
| (type $struct (struct)) | ||
|
|
||
| ;; CHECK: (type $1 (func (result i32 (ref (exact $struct))))) | ||
|
|
||
| ;; CHECK: (type $array (sub (array (mut i32)))) | ||
| (type $array (sub (array (mut i32)))) | ||
|
|
||
| ;; Trigger TypeSSA | ||
| ;; CHECK: (type $3 (func)) | ||
|
|
||
| ;; CHECK: (type $array_1 (sub $array (array (mut i32)))) | ||
|
|
||
| ;; CHECK: (type $5 (func (result i32 (ref $struct)))) | ||
|
|
||
| ;; CHECK: (global $array (ref $array) (array.new $array_1 | ||
| ;; CHECK-NEXT: (i32.const 0) | ||
| ;; CHECK-NEXT: (i32.const 0) | ||
| ;; CHECK-NEXT: )) | ||
| (global $array (ref $array) | ||
| (array.new $array | ||
| (i32.const 0) | ||
| (i32.const 0) | ||
| ) | ||
| ) | ||
|
|
||
| ;; CHECK: (func $caller (type $3) | ||
| ;; CHECK-NEXT: (call $callee) | ||
| ;; CHECK-NEXT: ) | ||
| (func $caller | ||
| ;; Give DAE a constant null parameter to optimize. | ||
| (tuple.drop 2 | ||
| (call $callee | ||
| (ref.null none) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ;; CHECK: (func $callee (type $3) | ||
| ;; CHECK-NEXT: (local $0 anyref) | ||
| ;; CHECK-NEXT: (tuple.drop 2 | ||
| ;; CHECK-NEXT: (block (type $1) (result i32 (ref (exact $struct))) | ||
| ;; CHECK-NEXT: (local.set $0 | ||
| ;; CHECK-NEXT: (ref.null none) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (block (type $1) (result i32 (ref (exact $struct))) | ||
| ;; CHECK-NEXT: (tuple.make 2 | ||
| ;; CHECK-NEXT: (i32.const 0) | ||
| ;; CHECK-NEXT: (struct.new_default $struct) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $callee (param (ref null any)) (result i32 (ref $struct)) | ||
| ;; When applying the constant null, DAE will create a block with | ||
| ;; (result i32 (ref (exact $struct))) | ||
| (block (result i32 (ref $struct)) | ||
| (tuple.make 2 | ||
| (i32.const 0) | ||
| (struct.new_default $struct) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ;; CHECK: (func $other (type $5) (result i32 (ref $struct)) | ||
| ;; CHECK-NEXT: (unreachable) | ||
| ;; CHECK-NEXT: ) | ||
| (func $other (result i32 (ref $struct)) | ||
| ;; This will keep the (result i32 (ref $struct)) signature, which will | ||
| ;; conflict with the (result i32 (ref (exact $struct))) of the block above | ||
| ;; after binary writing. This will not be observable, though, since DAE only | ||
| ;; optimizes non-referenced functions. TypeSSA should not crash or fail an | ||
| ;; assertion due to the repeated type shape. | ||
| (unreachable) | ||
| ) | ||
| ) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can't dae be run on this file in advance, and the testcase contain its results, and then only have type-ssa?
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 problem with trying to round-trip through text after DAE is that the conflicting rec groups are rejected by the parser after #8144, so the test would never get to running TypeSSA.
Maybe we should put more thought into trying to fix this in DAE to preserve the ability to do a text round trip after running it...
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.
Are you saying that DAE emits an invalid module? Or just invalid text?
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.
Only the text is invalid. The binary module will have the
exacterased, so it will just have two definitions of the same type, but that's not a correctness or validation problem.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.
We could consider generalizing types in the type printer the same way we do when we emit a binary, but I would be concerned about losing visibility into what's actually happening in the IR.
Uh oh!
There was an error while loading. Please reload this page.
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.
FWIW I just found that --block-merging can produce text modules with the same issue. Sample input:
This builds my confidence that simply removing the assertion is the best move.
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.
Yes, I agree that seems best. Please add a comment on the new
insertOrGetthough, explaining why it is ok to reuse existing types, and the rest of the stuff in this thread.