Skip to content

Layout::is_size_align_valid no longer inlined since 1.82.0 #149687

@RustyYato

Description

@RustyYato

Code

I tried this code:

use std::alloc::{Layout, LayoutError};

#[inline(never)]
pub fn test_1() -> Result<Layout, LayoutError> {
    Layout::from_size_align(4, 4)
}

https://rust.godbolt.org/z/seM4jzcWh

I expected to see this happen:

It should compile down to

example::test_1::hbf988c64c71bb848:
        mov     eax, 4
        mov     edx, 4
        ret

Instead, this happened:

It compiled down to (note the function call!)

example::test_1::h56b9105842f7b121:
        push    rax
        mov     edi, 4
        mov     esi, 4
        call    qword ptr [rip + core::alloc::layout::Layout::is_size_align_valid::h27157fff07002cf3@GOTPCREL]
        movzx   eax, al
        shl     eax, 2
        mov     edx, 4
        pop     rcx
        ret

Version it worked on

It most recently worked on: 1.81.0

Version with regression

Every version from 1.82.0 onwards has this regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library 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