[PATCH] D154695: [Coroutines] Add an O(n) algorithm for computing the cross suspend point information.

witstorm via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 19:10:22 PDT 2023


witstorm95 added a comment.

> I suggest to replace the current computeBlockData with 2 functions: collectConsumingBlock<bool SearchBackEdges>, collectKillingBlock. Then the semantics should be much more clear.

For code reuse, I don't really think split computeBlockData to 2 functions is good idea.



================
Comment at: llvm/lib/Transforms/Coroutines/CoroFrame.cpp:124
+  /// As we all know that topological sorting need to be used on DAG. But CFG
+  /// maybe not a DAG as CFG may have loop, so we need to break the loop.
+  /// If current CFG is a DAG, we just need to visit once. If current CFG is not
----------------
ChuanqiXu wrote:
> In the algorithm, I prefer to use the term `back edge` than `loop`. Since loop has many more meanings and attributes so that the back edges would be more precise.
> 
> Also with the new term `back edge`, we can describe the algorithm much more simpler:
> 1. In the initial iterations, all the consume information along the forward edges are collected.
> 2. (If there is any back edges), we can iterate again to get all the consume information along the back edges.
> 3. We can compute the Kill informations by the consume informations.
> 
> In this way, it is much easier to understand too.
@ChuanqiXu Thanks for your comment. 

I takes some time to figure out what means about terms like back edge and forward edge. Here is [[ https://courses.csail.mit.edu/6.006/fall11/rec/rec14.pdf | DFS Edge Classification]]. It's really suitable for topological sorting algorithm?

If we use that tems, I have some questions about your description of this algorithm:

> In the initial iterations, all the consume information along the forward edges are collected.
The Consume info should along the tree edge and back edge(if exists) are collected. And the same time, the Kill info should be collected too as we don't know there exists back edges or not in initial iteration.


> (If there is any back edges), we can iterate again to get all the consume information along the back edges.

The Consume info should along the tree edge and back edge are collected again and the Kill info should be collected too as you can't compute the all Kill informations in the third iteration only.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154695



More information about the llvm-commits mailing list