Skip to content

centralize -Zmin-function-alignment logic #142854

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

folkertdev
Copy link
Contributor

tracking issue: #82232
discussed in: #142824 (comment)

Apply the -Zmin-function-alignment value to the alignment field of the function attributes when those are created, so that individual backends don't need to consider it.

The one exception right now is cranelift, because it can't yet set the alignment for individual functions, but it can (and does) set the global minimum function alignment.

cc @RalfJung I think this is an improvement regardless, is there anything else that should be done for miri?

@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs

cc @jdonszelmann

@jieyouxu
Copy link
Member

r? codegen

@workingjubilee
Copy link
Member

This looks good to me.

r? workingjubilee
@bors r+

@bors
Copy link
Collaborator

bors commented Jun 22, 2025

📌 Commit a123a36 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 22, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 22, 2025
…-alignment, r=workingjubilee

centralize `-Zmin-function-alignment` logic

tracking issue: rust-lang#82232
discussed in: rust-lang#142824 (comment)

Apply the `-Zmin-function-alignment` value to the alignment field of the function attributes when those are created, so that individual backends don't need to consider it.

The one exception right now is cranelift, because it can't yet set the alignment for individual functions, but it can (and does) set the global minimum function alignment.

cc `@RalfJung` I think this is an improvement regardless, is there anything else that should be done for miri?
bors added a commit that referenced this pull request Jun 23, 2025
Rollup of 6 pull requests

Successful merges:

 - #140136 (Add an aarch64-msvc build running on ARM64 Windows)
 - #141597 (Document subdirectories of UI tests with README files)
 - #142823 (Port `#[no_mangle]` to new attribute parsing infrastructure)
 - #142828 (1.88.0 release notes)
 - #142854 (centralize `-Zmin-function-alignment` logic)
 - #142875 (Check rustdoc-json-types FORMAT_VERSION is correctly updated)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 23, 2025
Rollup of 5 pull requests

Successful merges:

 - #141597 (Document subdirectories of UI tests with README files)
 - #142823 (Port `#[no_mangle]` to new attribute parsing infrastructure)
 - #142828 (1.88.0 release notes)
 - #142854 (centralize `-Zmin-function-alignment` logic)
 - #142875 (Check rustdoc-json-types FORMAT_VERSION is correctly updated)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 57abad8 into rust-lang:master Jun 23, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 23, 2025
rust-timer added a commit that referenced this pull request Jun 23, 2025
Rollup merge of #142854 - folkertdev:centralize-min-function-alignment, r=workingjubilee

centralize `-Zmin-function-alignment` logic

tracking issue: #82232
discussed in: #142824 (comment)

Apply the `-Zmin-function-alignment` value to the alignment field of the function attributes when those are created, so that individual backends don't need to consider it.

The one exception right now is cranelift, because it can't yet set the alignment for individual functions, but it can (and does) set the global minimum function alignment.

cc ``@RalfJung`` I think this is an improvement regardless, is there anything else that should be done for miri?
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 23, 2025
…no-attributes, r=workingjubilee

fix `-Zmin-function-alignment` on functions without attributes

tracking issue: rust-lang#82232
related: rust-lang#142854

The minimum function alignment was skipped on functions without attributes (because the logic was in a loop that only runs if there is at least one attribute). The underlying reason we didn't catch this before is that in our testing we generally apply `#[no_mangle]` to functions that are tested. I've added a test now that deliberately has no attributes.

r? `@workingjubilee`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants