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

Tracking Issue for #[repr(align(...))] on function items (fn_align) #82232

Open
1 of 3 tasks
repnop opened this issue Feb 17, 2021 · 4 comments
Open
1 of 3 tasks

Tracking Issue for #[repr(align(...))] on function items (fn_align) #82232

repnop opened this issue Feb 17, 2021 · 4 comments
Labels
A-rust-for-linux Relevant for the Rust-for-Linux project C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@repnop
Copy link
Contributor

repnop commented Feb 17, 2021

This feature allows specifying an alignment for function items by adding the #[repr(align(...))] attribute to them.
The feature gate for the issue is #![feature(fn_align)]

Example

#[repr(align(16))]
fn requires_alignment() {
    // ...
}

Steps

@repnop repnop added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Feb 17, 2021
@repnop repnop changed the title Tracking Issue for #[repr(align = ...)] on function items (fn_align) Tracking Issue for #[repr(align(...))] on function items (fn_align) Feb 17, 2021
@evanrichter
Copy link
Contributor

Is it be possible to apply this to methods as well?

#![feature(fn_align)]

#[repr(align(1))]
fn main() {
    Bar::foo();
}

struct Bar;

impl Bar {
    #[repr(align(1))]
    fn foo() {
        println!("bar");
    }
}
error[E0517]: attribute should be applied to a struct, enum, function, or union
  --> src/main.rs:11:12
   |
11 |       #[repr(align(1))]
   |              ^^^^^^^^
12 | /     fn foo() {
13 | |         println!("bar");
14 | |     }
   | |_____- not a struct, enum, function, or union

For more information about this error, try `rustc --explain E0517`.
error: could not compile `asdf` due to previous error

@repnop
Copy link
Contributor Author

repnop commented Aug 26, 2021

I don't see why not? (I'm surprised it doesn't work already honestly lol) I'll see if I can find some time to investigate that and make another PR to allow that 👍

winksaville added a commit to winksaville/exper-borrowed-vs-owned-parameters that referenced this issue Dec 3, 2022
MessageMf has "Many fields" making it able to see how borrowed and
owned scale differently.

Added benchmarking creating default instances of Message and
MessageMf.

Removed the xxx_loop() variants as they don't add information just more
noise. I would like to look at why xxx_idx_loop() is sometimes slower
than xxx_iter_loop().

NOTE: I believe some of the noise is caused by code alignment changes
as we tweak that where doing and change code.
See: https://www.google.com/search?q=benchmark sensitive to code alignment
and rust-lang/rust#82232
@bunnie
Copy link
Contributor

bunnie commented Dec 25, 2022

Thanks for opening this, I just bumped my head into this exact problem as well!

@workingjubilee
Copy link
Contributor

This should come with a command-line flag to address the request made in #128830 for global code alignment control.

@workingjubilee workingjubilee added the A-rust-for-linux Relevant for the Rust-for-Linux project label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust-for-linux Relevant for the Rust-for-Linux project C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

No branches or pull requests

4 participants