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

David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 21:27:28 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)
----------------
david-xl wrote:

how is suspend lowered? will a tail call be inserted in the dest BB?

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


More information about the llvm-commits mailing list