[llvm] [profcheck][coro] Adding Branch weights PGO in Coroutines Passes (PR #184466)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 22:53:21 PDT 2026


================
@@ -1102,6 +1116,46 @@ void coro::SwitchCloner::create() {
   // Replacing coro.free with 'null' in cleanup to suppress deallocation code.
   if (FKind == coro::CloneKind::SwitchCleanup)
     elideCoroFree(NewFramePtr);
+
+  
+  // Update branch weights of the cloned resume switch if we have profile data.
+  if (Shape.ABI == coro::ABI::Switch) {
+    auto *ClonedSwitch = cast_if_present<SwitchInst>(
+        VMap[Shape.SwitchLowering.ResumeSwitch]);
+    if (ClonedSwitch) {
----------------
ChuanqiXu9 wrote:

nit: we prefer assignment in if

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


More information about the llvm-commits mailing list