Skip to content

InstanceDef::requires_inline does not result in an inline hint #79108

Closed
@tmiasko

Description

@tmiasko

The InstanceDef::requires_inline is described to return true if "this
instance is unconditionally marked with inline". In practice, the instance will
receive an inline hint if and only if the instance has any other user specified
inlining attributes.

For example, by default a closure will not receive an inline hint, but a
closure marked with #[inline(never)] counter-intuitively will (together with
noinline).

#![crate_type = "lib"]
#![feature(stmt_expr_attributes)]

pub fn f() {
    let a = || {};
    let b = #[inline(never)] || {};
    a();
    b();
}
; a::f::{{closure}}
; Function Attrs: nonlazybind uwtable
define internal void @"_ZN1a1f28_$u7b$$u7b$closure$u7d$$u7d$17hefe1f433f470c2abE"(%"[closure@a.rs:5:13: 5:18]"* noalias nonnull readonly align 1 %_1) unnamed_addr #0 {
start:
  ret void
}

; a::f::{{closure}}
; Function Attrs: inlinehint noinline nonlazybind uwtable
define internal void @"_ZN1a1f28_$u7b$$u7b$closure$u7d$$u7d$17h7b2e25d54194ec9cE"(%"[closure@a.rs:6:30: 6:35]"* noalias nonnull readonly align 1 %_1) unnamed_addr #1 {
start:
  ret void
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.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