[llvm] [coro][pgp] Do not insert counters in the `suspend` block (PR #71262)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 17:55:16 PST 2023


================
@@ -92,6 +94,39 @@ template <class Edge, class BBInfo> class CFGMST {
     return It->second.get();
   }
 
+  void handleCoroSuspendEdge(Edge *E) {
+    // We must not add instrumentation to the BB representing the
+    // "suspend" path, else CoroSplit won't be able to lower
+    // llvm.coro.suspend to a tail call. We do want profiling info for
+    // the other branches (resume/destroy). So we do 2 things:
+    // 1. we prefer instrumenting those other edges by setting the weight
+    //    of the "suspend" edge to max, and
+    // 2. we mark the edge as "Removed" to guarantee it is not considered
+    //    for instrumentation. That could technically happen:
+    //    (from test/Transforms/Coroutines/coro-split-musttail.ll)
+    //
+    // %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
----------------
ChuanqiXu9 wrote:

Technically, it depends on the frontend. For C++, yes.

The fancy part here is that symmetric transfer is a C++ feature. We just tried to implement it in the middle end. (This is not good. I know). So we can only consider C++ since the motivation of the patch to save symmetric transfer under pgo.

https://github.com/llvm/llvm-project/pull/71262


More information about the llvm-commits mailing list