cfallin requested alexcrichton for a review on PR #4652.
cfallin opened PR #4652 from opt-branches-at-end
to main
:
The
MachBuffer
applies a set of peephole-optimization rules to do
branch threading, leverage fallthrough paths, eliminate empty blocks,
and flip conditional branches where needed to make branches more
efficient starting from naive always-branch-at-end-of-BB code.This works by applying the rules at every label-bind, which is
equivalent to applying them at the end of every basic block, where
branches are usually inserted.However, this misses one case: the end of the buffer! Currently we
don't optimize any redundant or foldable branches at the very end of
the machine code.This usually doesn't matter when the function ends in an epilogue with
ret
as the last instruction. However, when cold blocks exist, it can
actually matter.Thanks to @mchesser for pointing out this issue in #4636.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
cfallin requested fitzgen for a review on PR #4652.
alexcrichton submitted PR review.
cfallin merged PR #4652.
Last updated: Dec 23 2024 at 12:05 UTC