Skip to content

Inlining small non-recursive functions #4472

Description

@catamorphism

I know that inlining heuristics are a black hole. However, it seems that we're growing lots of #[inline_always] attributes on small non-recursive functions. I have no idea what mechanism LLVM has for inlining hints (besides "always inline" annotations on a function), but telling it to always inline non-recursive functions below a certain size threshold would reduce the amount of clutter.

Activity

  1. Aatch commented on Jun 7, 2013

    @Aatch
    Contributor

    LLVM will potentially inline any function. It uses a threshold size for it, which is modified by inlinehint and overridden with always_inline.

  2. thestinger commented on Jun 7, 2013

    @thestinger
    Contributor

    It can't inline cross-crate though without #[inline] because we aren't usually outputting the AST.

  3. Aatch commented on Jun 7, 2013

    @Aatch
    Contributor

    @thestinger I'd say thats a separate issue. Either @huonw's #[inline(maybe)] makes it in, or we take a guess at intent and output the ast, sans #[inline] attribute.

  4. added a commit that references this issue on Jul 20, 2025
  5. added a commit that references this issue on Jul 21, 2025
  6. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions