Skip to content
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

Reclaim size regression for aligning fallthrough-only blocks #303

Draft
wants to merge 2 commits into
base: aie-public
Choose a base branch
from

Conversation

abhinay-anubola
Copy link
Collaborator

Yet to add tests

@abhinay-anubola abhinay-anubola force-pushed the sanubola.align.fallthrough.only.blocks branch from 8c4d73a to 3d412e5 Compare January 23, 2025 09:46
if (AlignOffset == 0)
return;
unsigned PadBytes = 16 - AlignOffset;
while (PadBytes) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand again. Could you please add a comment here? We have bundles formats that can only grow by four bytes, and we don't want to elongate these if they would overshoot the requested padding and others could supply an exact fit. Therefore we run in two stages, one which doesn't allow overshoot, and a second that does allow it. We may be forced to overshoot, in which case we will iterate the entire process. We will always terminate because we will saturate on full 16 byte bundles, which don't need padding.

@martien-de-jong
Copy link
Collaborator

martien-de-jong commented Jan 24, 2025

Looks good. I think the most important case is a block ending in a JNZ that is 2 bytes bigger than a multiple of 16 followed by a small block, e.g. one 32 bit instruction followed by a fallthrough. In the old situation you would pad the first block with 14 bytes and the second one with 12. In the new situation, you would only pad the second with 10 bytes.

Perhaps there are existing tests to check that the end of the function is aligned in the presence of fallthrough blocks. Otherwise one should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants