-
Notifications
You must be signed in to change notification settings - Fork 814
DeadArgumentElimination: Do not make private types public #7941
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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 |
---|---|---|
|
@@ -13,15 +13,15 @@ | |
|
||
(type $A (struct)) | ||
|
||
;; CHECK: (func $export (type $3) (result (ref $A)) | ||
;; CHECK: (func $export (type $func) (result anyref) | ||
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. Looks like this test needs updating (or at least the comment below does). |
||
;; CHECK-NEXT: (struct.new_default $A) | ||
;; CHECK-NEXT: ) | ||
(func $export (export "export") (type $func) (result anyref) | ||
;; We can refine to (ref $A), but not an exact one. | ||
(struct.new $A) | ||
) | ||
|
||
;; CHECK: (func $export-tuple (type $4) (result (ref $A) i32) | ||
;; CHECK: (func $export-tuple (type $func2) (result anyref i32) | ||
;; CHECK-NEXT: (tuple.make 2 | ||
;; CHECK-NEXT: (struct.new_default $A) | ||
;; CHECK-NEXT: (i32.const 42) | ||
|
@@ -36,3 +36,26 @@ | |
) | ||
) | ||
|
||
;; We can refine the array result to $array. However, doing so brings in the | ||
;; entire rec group of $array, which includes an exact type, which is not | ||
;; allowed when custom descriptors are disabled. | ||
(module | ||
;; CHECK: (type $func (sub (func (result (ref array))))) | ||
(type $func (sub (func (result (ref array))))) | ||
|
||
(rec | ||
;; CHECK: (rec | ||
;; CHECK-NEXT: (type $array (array i8)) | ||
(type $array (array i8)) | ||
;; CHECK: (type $unused (func (result (ref (exact $array))))) | ||
(type $unused (func (result (ref (exact $array))))) | ||
) | ||
|
||
;; CHECK: (func $test (type $func) (result (ref array)) | ||
;; CHECK-NEXT: (array.new_fixed $array 0) | ||
;; CHECK-NEXT: ) | ||
(func $test (export "test") (type $func) (result (ref array)) | ||
(array.new_fixed $array 0) | ||
) | ||
) | ||
|
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 |
---|---|---|
|
@@ -312,25 +312,70 @@ | |
|
||
;; CHECK: (type $2 (sub $func (func (result (ref (exact $A)))))) | ||
|
||
;; CHECK: (type $3 (func (result (ref $A)))) | ||
|
||
;; CHECK: (export "export" (func $export)) | ||
|
||
;; CHECK: (export "export2" (func $export2)) | ||
|
||
;; CHECK: (func $export (type $2) (result (ref (exact $A))) | ||
;; CHECK-NEXT: (struct.new_default $A) | ||
;; CHECK-NEXT: ) | ||
(func $export (export "export") (type $func) (result anyref) | ||
(struct.new $A) | ||
) | ||
|
||
;; CHECK: (func $export2 (type $3) (result (ref $A)) | ||
;; CHECK-NEXT: (unreachable) | ||
;; CHECK-NEXT: ) | ||
(func $export2 (export "export2") (result (ref $A)) | ||
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. Another option would be to just put |
||
;; Make $A public, so we are ok to refine $export. | ||
(unreachable) | ||
) | ||
) | ||
|
||
;; We do not refine the result if the type is final/closed, as we can't | ||
;; subtype it. | ||
(module | ||
;; CHECK: (type $A (struct)) | ||
|
||
;; CHECK: (type $func (func (result anyref))) | ||
(type $func (func (result anyref))) | ||
|
||
(type $A (struct)) | ||
|
||
;; CHECK: (type $2 (func (result (ref $A)))) | ||
|
||
;; CHECK: (export "export" (func $export)) | ||
|
||
;; CHECK: (export "export2" (func $export2)) | ||
|
||
;; CHECK: (func $export (type $func) (result anyref) | ||
;; CHECK-NEXT: (struct.new_default $A) | ||
;; CHECK-NEXT: ) | ||
(func $export (export "export") (type $func) (result anyref) | ||
(struct.new $A) | ||
) | ||
|
||
;; CHECK: (func $export2 (type $2) (result (ref $A)) | ||
;; CHECK-NEXT: (unreachable) | ||
;; CHECK-NEXT: ) | ||
(func $export2 (export "export2") (result (ref $A)) | ||
;; Make $A public, so we are ok to refine $export. | ||
(unreachable) | ||
) | ||
) | ||
|
||
;; We do not refine the result if the type is private, as that would make it | ||
;; public. | ||
(module | ||
;; CHECK: (type $func (sub (func (result anyref)))) | ||
|
||
;; CHECK: (type $A (struct)) | ||
(type $A (struct)) | ||
|
||
(type $func (sub (func (result anyref)))) | ||
|
||
;; CHECK: (export "export" (func $export)) | ||
|
||
;; CHECK: (func $export (type $func) (result anyref) | ||
|
@@ -340,3 +385,4 @@ | |
(struct.new $A) | ||
) | ||
) | ||
|
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.
It's actually much cheaper to just get the public types, since that only has to look at imports and exports.