[llvm] [Coroutines][LazyCallGraph] resumes are not really SCC (PR #116285)
Tyler Nowicki via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 14:22:26 PST 2024
TylerNowicki wrote:
I have had to do some studying on this to understand the discussion. I think I am able to follow it now.
The implementation of addSplitRefRecursiveFunctions, in the normal case, will create a new (Ref)SCC for the continuations. That is 1 (Ref)SCC to contain all the continuations. Then within this an SCC is created for each continuation individually. It does not actually require that any of the continuations directly call each other. Additionally, it doesn't attempt to merge any of these SCCs either. That seems reasonable because although one continuation will transitively reach the next this isn't done by a direct call. Instead, the coroutine caller is the one that invokes each continuation. Each continuation will contain a function ptr to the next and it is that which the coroutine caller invokes. Consequently, the continuations are each in their own SCC!
There is an additional special case that may reuse the (Ref)SCC of the original (ramp) function.
What I describe above does not hold for Switch ABI. In this ABI the resume, destroy and clean-up are individually added to the call graph with addSplitFunction(). This method handles 3 cases: 1) the new function has a direct call to any function in the original SCC, so it is in the same SCC, 2) the new function has a direct call to any function in the original (Ref)SCC, so it is in the same (Ref)SCC but not the same SCC, 3) no direct calls to the original (Ref)SCC/SCC, so it is in its own (Ref)SCC. The second case is what is handled by addSplitRefRecursiveFunctions for the group of continuations.
Based on this and what was said I believe the existing implementation of addSplitRefRecursiveFunctions is perfectly fine. It is only some of the comments and the debug code (already in this MR) that should be updated. I will update the MR to include these other changes. I have also started writing a discussion on the topic how coroutines update the call-graph that I will create a separate PR for soon.
Please let me know if anything I said is not accurate/correct.
https://github.com/llvm/llvm-project/pull/116285
More information about the llvm-commits
mailing list