-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Speed up alias analysis #7528
Speed up alias analysis #7528
Conversation
CT Test Results 2 files 294 suites 11m 7s ⏱️ Results for commit 0e97f10. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
Switch from the standard fixpoint algorithm for calculating liveness and from that deriving kill sets to a one-pass algorithm which calculates the kill sets directly. The algorithm traverses the basic blocks of the CFG post-order. It traverses the instructions within a basic block in reverse order, starting with the terminator. When starting the traversal of a basic block, the set of variables that are live is initialized to the variables that are live-in to the block's successors. When a def for a variable is found, it is pruned from the live set. When a use which is not in the live-set is found, it is a kill. The killed variable is added to the kill set for the current instruction and added to the live set. As the only back-edges occurring in BEAM are for receives and constructing terms are not allowed within the receive loop, back-edges can be safely ignored as they won't change the alias status of any variable. Acknowledgments to José Valim for suggesting that kill sets could be calculated directly.
Nothing happening in the exception block can propagate to the other blocks as it has no successors.
erlang:exit/1 will never return, so nothing that happens after the call can influence the aliasing status of a variable.
Variables which die in a basic block cannot influence the alias status of variables in successor blocks. By pruning dead variables, which are not part of a parent-child derivation relationship of live variables, the size of the active sharing state is reduced. The reduction in size speeds up subsequent `aa_merge_ss/3` operations. Combined with improved kill-set calculation (8545471) and an improved data structure for describing the alias status of variables (c389665), this patch provides a substantial reduction of the time required for alias analysis. For the set of modules compiled by `scripts/diffable` the time spent in alias analysis is reduced by approximately 55%. For the example in Issue erlang#7432 [1], provided by José Valim, which has a large number of variables, the reduction is even more dramatic. The time spent in the alias analysis pass is reduced by 97%. [1] erlang#7432 Closes: erlang#7432
add4fe5
to
786277f
Compare
Fixed Dialyzer error and rebase to pick up CI-fixes. |
Remove commented out code and turn trace printouts into proper ?DP()-invocations.
786277f
to
0e97f10
Compare
Merged, thanks for the PR! |
Combined with improved kill-set calculation (8545471) and an improved data
structure for describing the alias status of variables (c389665), this patch series provides a substantial reduction of the time required for alias analysis. For the set of modules compiled by
scripts/diffable
the time spent in alias analysis is reduced by approximately 55%. For the example in Issue #7432, provided by José Valim, which has a large number of variables, the reduction is even more dramatic. The time spent in the alias analysis pass is reduced by 97%.