-
Notifications
You must be signed in to change notification settings - Fork 788
Generalize "trivial call" flag to other simple instructions #7670
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
Draft
osa1
wants to merge
18
commits into
WebAssembly:main
Choose a base branch
from
osa1:generalize_is_trivial_call
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.
+466
−30
Conversation
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
A "trivial call" is a function that just calls another function. (func $foo ... (call $target ...)) Currently we inline these functions always only when not optimizing for code size. When optimizing for code size, these functions can always be inlined when 1. The arguments to `$target` are all function argument locals. 2. The locals are not used more than once 3. The locals are used in the same order they appear in the function arguments. When these hold, inlining `$foo` never increases code size as it doesn't cause introducing more locals at call sites. Improve `FunctionInfo` type and `FunctionInfoScanner` to annotate functions with "trivial call" information that also contains whether inlining shrinks code size. If a function shrinks when inlined always inline it even with `-Os`. Otherwise inline it as before, i.e. when not optimizing for code size.
An option is to create a PR in your fork, and ping people there. That's what I usually do. (Then, after the parent branch lands in upstream, you need to create a new PR there, so there is a downside...) Though, perhaps it makes sense to focus on the first PR for now? |
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.
Note: this is based on #7669. I can't create a PR to that branch as the branch lives in my my fork.
I can merge this to #7669 if that's more helpful than a separate PR?
A "trivial call" function is a function that just calls another with
local.get
s as arguments.These functions can sometimes be inlined when optimizing for size.
With this PR we generate "trivial call" flag to "trivial instruction", to cover binary instructions like
i32.add
and unary instructions likei32.eqz
.With this PR wasm-opt now inlines trivial functions in dart2wasm outputs like:
Note: dart2wasm doesn't directly generate these functions, these become "trivial" after wasm-opt passes.