Skip to content

Regression in inlining performance from 1.82.0 #143513

Open
@Guilucand

Description

@Guilucand

Hi, I found a suboptimal code generation while inlining some struct functions starting from Rust 1.82.0 (including nightly).

Here's a link to a compiler explorer minimal example:
https://godbolt.org/z/WKqMr1fE7

In Rust < 1.82.0 the code is optimized correctly, while in versions above the code is different and an inefficient imul instruction appears, causing a major performance drop during execution.

It seems that the problem is already present in the generated llvm IR (generated with --emit=llvm-ir).

I tested various configurations in Rust 1.82.0:

  • Debug symbols disabled => suboptimal
  • TestStruct without #[repr(C)] and -C debuginfo=2 => suboptimal
  • TestStruct with #[repr(C)] and -C debuginfo=2 => correct

I also uploaded the code to github:
https://github.com/Guilucand/rust-inlining-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions