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

[BOLT] Return proper minimal alignment from BF #67707

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Conversation

yota9
Copy link
Member

@yota9 yota9 commented Sep 28, 2023

Currently minimal alignment of function is hardcoded to 2 bytes.
Add 2 more cases:

  1. In case BF is data in code return the alignment of CI as minimal
    alignment
  2. For aarch64 and riscv platforms return the minimal value of 4 (added
    test for aarch64)
    Otherwise fallback to returning the 2 as it previously was.

@yota9
Copy link
Member Author

yota9 commented Sep 28, 2023

@maksfb I fill like setting minimal required alignment per BF is more proper way to fix the CI alignment issue to be honest. So we would have "minimal alignment" field that is the BFs guaranteed alignment that we would have and the alignment/maxbyte alignment non guaranteed logic. What do you think? Thanks!

bolt/lib/Passes/Aligner.cpp Outdated Show resolved Hide resolved
@yota9 yota9 requested a review from maksfb September 28, 2023 18:02
@yota9 yota9 added the BOLT label Sep 29, 2023
@maksfb
Copy link
Contributor

maksfb commented Oct 2, 2023

@maksfb I fill like setting minimal required alignment per BF is more proper way to fix the CI alignment issue to be honest. So we would have "minimal alignment" field that is the BFs guaranteed alignment that we would have and the alignment/maxbyte alignment non guaranteed logic. What do you think? Thanks!

Sounds like we should handle CIs separately from BFs.

@yota9
Copy link
Member Author

yota9 commented Oct 2, 2023

A few years ago I had the same feelings. Right now I'm not really sure how to re-design the code to handle them separately to be honest.

@maksfb
Copy link
Contributor

maksfb commented Oct 2, 2023

Do you anticipate different CIs to have different min alignments in the future? If not, I would rather modify the newly added getMinAlignment() to return a correct value based on the underlying arch and the type of object. Turning MinAlign into a field needs a justification.

@yota9
Copy link
Member Author

yota9 commented Oct 3, 2023

Well, what's came in to my mind is the golang functions, that needs at least the 16 bytes alignment. But I agree that for now we can check everything and return the result from getMinAlignment() function, let me update the review later. Thanks!

Currently minimal alignment of function is hardcoded to 2 bytes.
Add 2 more cases:
1. In case BF is data in code return the alignment of CI as minimal
alignment
2. For aarch64 and riscv platforms return the minimal value of 4 (added
test for aarch64)
Otherwise fallback to returning the 2 as it previously was.
@yota9 yota9 changed the title [BOLT][NFC] Set minimal alignment for BF [BOLT] Return proper minimal alignment from BF Oct 3, 2023
@yota9
Copy link
Member Author

yota9 commented Oct 5, 2023

Gentle ping

@yota9
Copy link
Member Author

yota9 commented Oct 10, 2023

@maksfb gentle ping

Copy link
Contributor

@maksfb maksfb left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@yota9 yota9 merged commit b7944f7 into llvm:main Oct 12, 2023
3 checks passed
mtvec added a commit to mtvec/llvm-project that referenced this pull request Oct 23, 2023
In llvm#67707, the minimum function alignment on RISC-V was set to 4. When
RVC (compressed instructions) is enabled, the minimum alignment can be
reduced to 2.

This patch implements this by delegating the choice of minimum alignment
to a new `MCPlusBuilder::getMinFunctionAlignment` function. This way,
the target-dependent code in `BinaryFunction` is minimized.
mtvec added a commit that referenced this pull request Oct 23, 2023
In #67707, the minimum function alignment on RISC-V was set to 4. When
RVC (compressed instructions) is enabled, the minimum alignment can be
reduced to 2.

This patch implements this by delegating the choice of minimum alignment
to a new `MCPlusBuilder::getMinFunctionAlignment` function. This way,
the target-dependent code in `BinaryFunction` is minimized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants