[PATCH] D131938: [C++20] [Coroutines] Disable to take the address of labels in coroutines

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 22:27:51 PDT 2022


ChuanqiXu added a comment.

In D131938#3727954 <https://reviews.llvm.org/D131938#3727954>, @ychen wrote:

>> Since the coroutines are going to split into pieces in the middle end so the address of labels are ambiguous that time.
>
> Do we split in the middle or copy the whole computed goto CFG?

Yes.

> I'd imagine the branch on a dynamic block address is like `n`-way branch which is not feasible to split. Does/Would it fix the problem by letting the ramp/resume function each have its own dispatch table? I skimmed through the blockaddress handling during function cloning which looks insufficient to handle this issue: https://github.com/llvm/llvm-project/blob/e20d210eef92f3952de0e89ef2f01a146480a13b/llvm/lib/Transforms/Utils/CloneFunction.cpp#L177-L182, it says "It is only legal to clone a function if a block address within that function is never referenced outside of the function." . This is not true when the dispatch table is a global variable.

The key problem here is that the compiler don't know the idea 'dispatch table'. The dispatch table is just a global variable. And coroutines should just leave the global variable there just like other global variables.

> "It is only legal to clone a function if a block address within that function is never referenced outside of the function."

This also shows the problem. The coroutines are multiple functions indeed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131938/new/

https://reviews.llvm.org/D131938



More information about the cfe-commits mailing list