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

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 17:32:49 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)
----------------
mtrofin wrote:

Right, and moreover the `-1` case should reduce to `ret`, correct?

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


More information about the llvm-commits mailing list