This is an archive of the discontinued LLVM Phabricator instance.

[Coroutines] Introduce "coro_readnone" operand bundles (2/3)
AbandonedPublic

Authored by ChuanqiXu on May 9 2022, 11:56 PM.

Details

Summary

This belongs to a series of patches which try to solve the thread identification problem in coroutines. See https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015 for a full background.

This patch tries to solve the readnone problem by removing the readnone attributes for calls in a coroutine in CoroEarly pass. And we would add the readnone attribute back after the coroutine get split in CoroCleanup pass. To record the calls we removed the attribute and block unexpect optimizations, we introduced "coro_readnone" operand bundles.

Why operand bundles instead of another attribute on the callsite?

Since when the compiler query whether a call is readnone, it would try to lookup to the callee declaration of the call if it failed to find the attribute at the callsite. See https://github.com/llvm/llvm-project/blob/3b762b3ab8d205cd6a7d42c96d39d5f4f701f2ab/llvm/include/llvm/IR/InstrTypes.h#L2315-L2325

The method would only try to process coroutines only to avoid affecting thousands of normal functions.

Diff Detail

Event Timeline

ChuanqiXu created this revision.May 9 2022, 11:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 11:56 PM
ChuanqiXu requested review of this revision.May 9 2022, 11:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 11:56 PM
ChuanqiXu edited the summary of this revision. (Show Details)May 9 2022, 11:59 PM
ChuanqiXu added inline comments.May 10 2022, 1:52 AM
llvm/lib/Transforms/Coroutines/CoroEarly.cpp
238–244

@rjmccall Could we remove the check now? If yes, we could add a check in the beginning of the function to return quickly for normal functions.

Although this one is marked (2/3) in the title, it is independent with the previous revision logically. We could review and submit this one independently.

@rjmccall @eli.friedman @jyknight gentle ping~

efriedma added a subscriber: efriedma.

I don't think we reached a consensus this is the right approach; please ping the Discourse thread.

I don't think we reached a consensus this is the right approach; please ping the Discourse thread.

Oh, I misread the thread.. I translated it as 'no objections...', will do.

ChuanqiXu edited reviewers, added: efriedma; removed: eli.friedman.May 18 2022, 7:30 PM