-
Notifications
You must be signed in to change notification settings - Fork 747
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
[EH] Test StackIR's local2stack on translator output #6264
Merged
aheejin
merged 1 commit into
WebAssembly:main
from
aheejin:eh_translator_stackir_opt_test
Feb 1, 2024
Merged
[EH] Test StackIR's local2stack on translator output #6264
aheejin
merged 1 commit into
WebAssembly:main
from
aheejin:eh_translator_stackir_opt_test
Feb 1, 2024
Conversation
This file contains 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 addes `STACKIR-OPT` filecheck lines to `translate-to-new-eh.wast` to see if StackIR's `local2stack` optimization successfully removes some of unnecessary `local.set`/`local.get`s. While supporting the whole Binayren optimization pipeline for the new EH instructions is not the goal for the very near-term future, StackIR's `local2stack` optimization can help with a very common pattern generated by this translator, which is: ```wast (try $l (do ... ) (catch_all (call $destructor) (rethrow $l) ) ) ``` is translated to ``` (block $outer (local.set $exn ;; can be optimized away (block $catch_all (result exnref) (try_table (catch_all_ref $catch_all) ... ) (br $outer) ) ) (call $destructor) (throw_ref (local.get $exn) ;; can be optimized away ) ) ``` Here we don't really need `local.set $exn` and `local.get $exn`, and these can be optimized away using StackIR's local2stack. After optimizing them away in Stack IR, the code can be like ```wast block $outer block $catch_all (result exnref) try_table (catch_all_ref $catch_all) ... end br $outer end call $destructor throw_ref ``` This optimization alone reduces the code size increased caused by translating significantly. For Adobe Photoshop, the code size increase goes down from 4.2% to 2.8%, and for Binaryen, it goes down from 3.8% to 2.0%.
kripken
approved these changes
Feb 1, 2024
;; STACKIR-OPT-NEXT: end | ||
;; STACKIR-OPT-NEXT: throw_ref | ||
;; STACKIR-OPT-NEXT: end | ||
;; STACKIR-OPT-NEXT: ) |
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.
Nice, looks like this is an example of those local.set/get
operations getting removed.
tlively
approved these changes
Feb 1, 2024
radekdoulik
pushed a commit
to dotnet/binaryen
that referenced
this pull request
Jul 12, 2024
This adds `STACKIR-OPT` filecheck lines to `translate-to-new-eh.wast` to see if StackIR's `local2stack` optimization successfully removes some of unnecessary `local.set`/`local.get`s. While supporting the whole Binayren optimization pipeline for the new EH instructions is not the goal for the very near-term future, StackIR's `local2stack` optimization can help with a very common pattern generated by this translator, which is: ```wast (try $l (do ... ) (catch_all (call $destructor) (rethrow $l) ) ) ``` is translated to ```wast (block $outer (local.set $exn ;; can be optimized away (block $catch_all (result exnref) (try_table (catch_all_ref $catch_all) ... ) (br $outer) ) ) (call $destructor) (throw_ref (local.get $exn) ;; can be optimized away ) ) ``` Here we don't really need `local.set $exn` and `local.get $exn`, and these can be optimized away using StackIR's local2stack. After optimizing them away in Stack IR, the code can be like ```wast block $outer block $catch_all (result exnref) try_table (catch_all_ref $catch_all) ... end br $outer end call $destructor throw_ref end ``` This optimization alone reduces the code size increased caused by translating significantly. For Adobe Photoshop, the code size increase goes down from 4.2% to 2.8%, and for Binaryen, it goes down from 3.8% to 2.0%.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds
STACKIR-OPT
filecheck lines totranslate-to-new-eh.wast
to see if StackIR'slocal2stack
optimization successfully removes some of unnecessarylocal.set
/local.get
s.While supporting the whole Binayren optimization pipeline for the new EH instructions is not the goal for the very near-term future, StackIR's
local2stack
optimization can help with a very common pattern generated by this translator, which is:is translated to
Here we don't really need
local.set $exn
andlocal.get $exn
, and these can be optimized away using StackIR's local2stack. After optimizing them away in Stack IR, the code can be likeThis optimization alone reduces the code size increased caused by translating significantly. For Adobe Photoshop, the code size increase goes down from 4.2% to 2.8%, and for Binaryen, it goes down from 3.8% to 2.0%.