Skip to content

[Coroutine] Coroutine collect unneeded variables to coroutine frame. #49716

@llvmbot

Description

@llvmbot
Bugzilla Link 50372
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

I am not sure if it is OK to mark this with a bug. It is like a feature more to me. I mark this with bugzilla since I found this: #44911 , which tells an optimization instead of a bug.

The motivation example comes from: https://godbolt.org/z/c4zx9fE88.

The key codes is:

cppcoro::task<int> simple() noexcept {
    // 552 byte coroutine frame
    char dummy[500];
    for (int i = 0;i < 500; i++)
        dummy[i] = rand()%8;
    consume(dummy[rand()%500]);
    co_await std::experimental::suspend_always{};
    co_return 10;
}

Here we can find that the dummy isn't used across suspend point. So the dummy could show as a stack variable. If compilers could optimize this, we could get a smaller coroutine frame.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++20coroutinesC++20 coroutinesenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions