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

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 16:50:28 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Transforms/Coroutines/CoroFrame.cpp llvm/lib/Transforms/Coroutines/CoroSplit.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index a8d5f1aa5..3cf915d53 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -435,8 +435,8 @@ void coro::BaseCloner::handleFinalSuspend() {
       auto *Cond = Builder.CreateIsNull(Load);
       auto *Br = Builder.CreateCondBr(Cond, ResumeBB, NewSwitchBB);
       applyProfMetadataIfEnabled(Br, [&](Instruction *Inst) {
-        setExplicitlyUnknownBranchWeightsIfProfiled(
-            *Inst, DEBUG_TYPE, Inst->getFunction());
+        setExplicitlyUnknownBranchWeightsIfProfiled(*Inst, DEBUG_TYPE,
+                                                    Inst->getFunction());
       });
     }
     OldSwitchBB->getTerminator()->eraseFromParent();
@@ -1610,14 +1610,17 @@ private:
         SmallVector<uint32_t> Weights;
         // Add the Unlikly weight for the default case.
         Weights.push_back(llvm::MDBuilder::kUnlikelyBranchWeight);
-        // The first case (IndexVal == 0) represents the coroutine initialization, 
-        // which is expected to be the most common case, so we give it the highest weight. 
+        // The first case (IndexVal == 0) represents the coroutine
+        // initialization, which is expected to be the most common case, so we
+        // give it the highest weight.
         Weights.push_back(llvm::MDBuilder::kLikelyBranchWeight);
-        // Remaning cases are unlikely to be hit, so we give them the unlikely weight.
+        // Remaning cases are unlikely to be hit, so we give them the unlikely
+        // weight.
         for (size_t i = 1, e = Shape.CoroSuspends.size(); i < e; ++i)
           Weights.push_back(llvm::MDBuilder::kUnlikelyBranchWeight);
         MDBuilder MDB(C);
-        Switch->setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));
+        Switch->setMetadata(LLVMContext::MD_prof,
+                            MDB.createBranchWeights(Weights));
       }
     }
 
@@ -1646,8 +1649,8 @@ private:
       // allocation, use CleanupFn instead of DestroyFn).
       DestroyOrCleanupFn = Builder.CreateSelect(CA, DestroyFn, CleanupFn);
       applyProfMetadataIfEnabled(DestroyOrCleanupFn, [&](Instruction *Inst) {
-        setExplicitlyUnknownBranchWeightsIfProfiled(*Inst, DEBUG_TYPE, 
-                                                     CoroId->getFunction());
+        setExplicitlyUnknownBranchWeightsIfProfiled(*Inst, DEBUG_TYPE,
+                                                    CoroId->getFunction());
       });
     }
 

``````````

</details>


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


More information about the llvm-commits mailing list