-
Notifications
You must be signed in to change notification settings - Fork 779
[Strings] Automate string lifting and lowering in the optimization pipeline #7540
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
Open
kripken
wants to merge
33
commits into
WebAssembly:main
Choose a base branch
from
kripken:auto.strings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
aac7e4b
start
kripken 258a8cf
test
kripken 21be4e4
nop
kripken 3f37536
work
kripken 2db78d1
work
kripken 59138a5
minimal fix for test
kripken 38683e2
undo
kripken c883cef
optimize
kripken bbe5169
style
kripken 214b94c
fix
kripken 0cbd372
help
kripken a6cc9c8
anoter way
kripken 0546b6f
work
kripken 6ddd59c
work
kripken 6049fc9
update
kripken 0f7565a
work
kripken 0dd90e8
fix
kripken 60ce65c
work
kripken 618cf3e
work
kripken 13e3fd4
work
kripken 0083cae
format
kripken 1da2e68
test
kripken 6f6f5ca
note
kripken 107697e
work
kripken 4237c4d
guard
kripken 5430567
fix
kripken bc97fe2
test
kripken d8fd20e
fuzzer fix
kripken 61e1c1a
oops
kripken 6cb8b9a
make the string-*-paired passes internal/test, so they don't clutter …
kripken 4db0890
update
kripken 911df99
Add a flag for convenient disabling of string lowering
kripken 766fadc
Merge remote-tracking branch 'origin/main' into auto.strings
kripken 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
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
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
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
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,55 @@ | ||
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. | ||
|
||
;; Run -O2 and then -O3. Both the -O2 and -O3 should lift and lower strings. If | ||
;; the -O2 somehow prevented the -O3 from doing so (say, forgetting to reset the | ||
;; state between the paired lifting and lowering pass) then we would see that | ||
;; -O3 failed to fully optimize, as the function here requires | ||
;; --precompute-propagate which only -O3 does. | ||
|
||
;; RUN: foreach %s %t wasm-opt -O2 -O3 -all -S -o - | filecheck %s | ||
|
||
(module | ||
(type $array16 (array (mut i16))) | ||
|
||
(import "\'" "foo" (global $foo (ref extern))) | ||
|
||
(import "\'" "bar" (global $bar (ref extern))) | ||
|
||
(import "wasm:js-string" "concat" (func $concat (param externref externref) (result (ref extern)))) | ||
|
||
;; CHECK: (type $0 (func (result (ref extern)))) | ||
|
||
;; CHECK: (import "\'" "foobarbar" (global $"string.const_\"foobarbar\"" (ref extern))) | ||
|
||
;; CHECK: (export "string.concat" (func $string.concat)) | ||
|
||
;; CHECK: (func $string.concat (type $0) (result (ref extern)) | ||
;; CHECK-NEXT: (global.get $"string.const_\"foobarbar\"") | ||
;; CHECK-NEXT: ) | ||
(func $string.concat (export "string.concat") (result (ref extern)) | ||
(local $x (ref extern)) | ||
(local $y (ref extern)) | ||
;; -O2 does not propagate the string constants through the locals, but -O3 | ||
;; will, allowing this function to return the concatenated final string. | ||
(local.set $x | ||
(global.get $foo) | ||
) | ||
(local.set $y | ||
(global.get $bar) | ||
) | ||
;; Add an extra concat that is written to $x, so the local has multiple | ||
;; writes (otherwise, simplify-locals manages to remove the locals, and -O2 | ||
;; does just as well as -O3). | ||
(local.set $x | ||
(call $concat | ||
(local.get $x) | ||
(local.get $y) | ||
) | ||
) | ||
(call $concat | ||
(local.get $x) | ||
(local.get $y) | ||
) | ||
) | ||
) |
Oops, something went wrong.
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.
Do we need
string-gathering
at all any more, or can we remove its code?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 don't need it for users, though it is nice for testing. I can make it a testing pass as a followup?
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.
Sounds good to me.