Skip to content

#[inline(never)] does not work for async functions #129347

@michaelwoerister

Description

@michaelwoerister

I would expect the following code produced a Future::poll() impl with the noinline attribute.

#![feature(noop_waker)] use std::task::{Context, Waker, Poll}; use std::future::Future; #[inline(never)] pub async fn foo() -> u32 { std::hint::black_box(1) } pub fn bar() -> Poll<u32> { let f = std::pin::pin!(foo()); f.poll(&mut Context::from_waker(Waker::noop())) }

Instead, the poll method has inlinehint applied to it and gets inlined accordingly:

; This is the function creating the async fn obj: ; Function Attrs: noinline nonlazybind uwtable define i8 @_RNvCs8Nh0J9OTdDr_15async_fn_inline3foo() unnamed_addr #2 { %1 = alloca [1 x i8], align 1 store i8 0, ptr %1, align 1 %2 = load i8, ptr %1, align 1 ret i8 %2 } ; This the poll method: ; Function Attrs: inlinehint nonlazybind uwtable <== this should arguably be noinline too define internal { i32, i32 } @_RNCNvCs8Nh0J9OTdDr_15async_fn_inline3foo0B3_(...)

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (636d7ff91 2024-08-19) binary: rustc commit-hash: 636d7ff91b9847d6d43c7bbe023568828f6e3246 commit-date: 2024-08-19 host: x86_64-unknown-linux-gnu release: 1.82.0-nightly LLVM version: 19.1.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-async-awaitArea: Async & AwaitA-codegenArea: Code generationAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-langRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions