[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 13:21:01 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:
IIUC, `llvm.coro.suspend` is really a marker that says "return. Upon resumption, here's where you go if there's more to execute, and here's where you go if we're done". So it's not really a call, and the switch isn't really a switch, and the "default" path of the switch really needs to reduce to `ret`.
Adding @GorNishanov to check my understanding.
https://github.com/llvm/llvm-project/pull/71262
More information about the llvm-commits
mailing list