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

Fix #[inline(always)] for recursive functions #599

Open
antoyo opened this issue Jan 15, 2025 · 0 comments
Open

Fix #[inline(always)] for recursive functions #599

antoyo opened this issue Jan 15, 2025 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@antoyo
Copy link
Contributor

antoyo commented Jan 15, 2025

The following code:

#[inline(always)]
fn my_func(arg: i32) {
    if arg > 1 {
        my_func(arg - 1);
    }
}

fn main() {
    my_func(10);
}

triggers the following error:

libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_ZN9test_rust7my_func17h0d9fc1667ee3d8a0E’: function not considered for inlining
libgccjit.so: src/main.rs:4:9: note: : called from here

As noted here, always_inline is not an optimization hint while #[inline(always)] is a hint as noted in the reference.

I'm not sure what the equivalent would be in GCC, though.

Maybe check what clang is doing (since it also has the issue) vs what rustc is doing.

#[rustc_force_inline] is possibly implemented via always_inline.

@antoyo antoyo added bug Something isn't working help wanted Extra attention is needed labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant