-
Notifications
You must be signed in to change notification settings - Fork 859
OptimizeCasts: Migrate from invalidates to orderedBefore #8774
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
+154
−5
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
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,149 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. | ||
| ;; RUN: wasm-opt %s --optimize-casts -all -S -o - | filecheck %s | ||
|
|
||
| (module | ||
| ;; CHECK: (type $A (sub (struct))) | ||
| (type $A (sub (struct))) | ||
| ;; CHECK: (type $B (sub $A (struct))) | ||
| (type $B (sub $A (struct))) | ||
|
|
||
| (memory 1) | ||
|
|
||
| ;; CHECK: (global $g (mut i32) (i32.const 0)) | ||
| (global $g (mut i32) (i32.const 0)) | ||
|
|
||
| ;; CHECK: (func $cast_allowed (type $2) (param $x (ref null $A)) | ||
| ;; CHECK-NEXT: (local $temp (ref null $A)) | ||
| ;; CHECK-NEXT: (local $2 (ref null $B)) | ||
| ;; CHECK-NEXT: (local.set $temp | ||
| ;; CHECK-NEXT: (local.get $x) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (block | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (local.tee $2 | ||
| ;; CHECK-NEXT: (ref.cast (ref null $B) | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (i32.load | ||
| ;; CHECK-NEXT: (i32.const 0) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.cast (ref null $B) | ||
| ;; CHECK-NEXT: (local.get $2) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $cast_allowed (param $x (ref null $A)) | ||
| ;; ref.cast can move back past load. | ||
| (local $temp (ref null $A)) | ||
| (local.set $temp (local.get $x)) | ||
| (block | ||
| (drop (local.get $temp)) | ||
| (drop (i32.load (i32.const 0))) | ||
| (drop (ref.cast (ref null $B) (local.get $temp))) | ||
| ) | ||
| ) | ||
|
|
||
| ;; CHECK: (func $cast_disallowed (type $2) (param $x (ref null $A)) | ||
| ;; CHECK-NEXT: (local $temp (ref null $A)) | ||
| ;; CHECK-NEXT: (local.set $temp | ||
| ;; CHECK-NEXT: (local.get $x) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (block | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (i32.store | ||
| ;; CHECK-NEXT: (i32.const 0) | ||
| ;; CHECK-NEXT: (i32.const 42) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.cast (ref null $B) | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $cast_disallowed (param $x (ref null $A)) | ||
| ;; ref.cast cannot move back past a store. | ||
| (local $temp (ref null $A)) | ||
| (local.set $temp (local.get $x)) | ||
| (block | ||
| (drop (local.get $temp)) | ||
| (i32.store (i32.const 0) (i32.const 42)) | ||
| (drop (ref.cast (ref null $B) (local.get $temp))) | ||
| ) | ||
| ) | ||
|
|
||
| ;; Test 3: ref.as positive (moves past mutable global read) | ||
| ;; CHECK: (func $as_allowed (type $3) (param $x anyref) | ||
| ;; CHECK-NEXT: (local $temp anyref) | ||
| ;; CHECK-NEXT: (local $2 (ref any)) | ||
| ;; CHECK-NEXT: (local.set $temp | ||
| ;; CHECK-NEXT: (local.get $x) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (block | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (local.tee $2 | ||
| ;; CHECK-NEXT: (ref.as_non_null | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (global.get $g) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.as_non_null | ||
| ;; CHECK-NEXT: (local.get $2) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $as_allowed (param $x anyref) | ||
| ;; ref.as_non_null can move back past a global.get. | ||
| (local $temp anyref) | ||
| (local.set $temp (local.get $x)) | ||
| (block | ||
| (drop (local.get $temp)) | ||
| (drop (global.get $g)) | ||
| (drop (ref.as_non_null (local.get $temp))) | ||
| ) | ||
| ) | ||
|
|
||
| ;; Test 4: ref.as negative (blocked by mutable global write) | ||
| ;; CHECK: (func $as_disallowed (type $3) (param $x anyref) | ||
| ;; CHECK-NEXT: (local $temp anyref) | ||
| ;; CHECK-NEXT: (local.set $temp | ||
| ;; CHECK-NEXT: (local.get $x) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (block | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (global.set $g | ||
| ;; CHECK-NEXT: (i32.const 42) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.as_non_null | ||
| ;; CHECK-NEXT: (local.get $temp) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $as_disallowed (param $x anyref) | ||
| ;; ref.as_non_null cannot move back past a global.set. | ||
| (local $temp anyref) | ||
| (local.set $temp (local.get $x)) | ||
| (block | ||
| (drop (local.get $temp)) | ||
| (global.set $g (i32.const 42)) | ||
| (drop (ref.as_non_null (local.get $temp))) | ||
| ) | ||
| ) | ||
| ) |
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.
Why this change?
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 is a fix to unrelated tests that were breaking CI. I landed this separately in #8777.