-
Notifications
You must be signed in to change notification settings - Fork 787
BranchHintAnalysis pass #7625
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
kripken
wants to merge
64
commits into
WebAssembly:main
Choose a base branch
from
kripken:bha
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.
Draft
BranchHintAnalysis pass #7625
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
This reverts commit cd19403.
Is that 3-50% of original code size or number of hints? |
Number of hints. So if function analysis gives 100 hints in the entire module, cross-function analysis adds 3-50 on top. |
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 pass statically infers branch hint annotations, inspired by
LLVM's BranchProbabilityInfo:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/BranchProbabilityInfo.cpp
So far this sets low priority for throwing paths and even lower for
unreachable ones. It propagates such indications back to calling
blocks and even calling functions.
LLVM does a little more, it also has some minor hints for things like
a float being NaN (unlikely) and an integer/pointer being 0 (unlikely),
etc.
This pass has no benefit I can measure. My best guess is that we mostly
end up marking exit paths from functions (error handling, etc.), and VMs
can place those blocks and regalloc them efficiently without our hints.
The cross-function part can't be done by VMs, and adds a signficant
amount of hints (3-50% on real-world binaries) but even that does not
help any benchmark I have tried (Emscripten benchmark suite). Opening
this PR as draft to share that information, and maybe as a basis for future
work.