[llvm] [profcheck][coro] Adding Branch weights PGO in Coroutines Passes (PR #184466)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 08:42:06 PDT 2026
================
@@ -412,6 +418,21 @@ void coro::BaseCloner::handleFinalSuspend() {
auto *Switch = cast<SwitchInst>(VMap[Shape.SwitchLowering.ResumeSwitch]);
auto FinalCaseIt = std::prev(Switch->case_end());
BasicBlock *ResumeBB = FinalCaseIt->getCaseSuccessor();
+
+ // If there is branch weight metadata, and we are about to remove the last
+ // case, update the metadata by removing the last weight.
----------------
mtrofin wrote:
how was the last case removed, i.e. was it folded somewhere else, or was it unreachable and then its probability should be 0?
because just removing the weight may not be correct - that changes the denominator of the fraction that forms the probability of each branch: the probability of the `i`th branch is its weight divided by the sum of all the weights associated with that instruction.
https://github.com/llvm/llvm-project/pull/184466
More information about the llvm-commits
mailing list