[llvm] [MergeFunctions] Preserve entry counts on folds (PR #202218)

Alok Kumar Sharma via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 22 23:31:15 PDT 2026


================
@@ -916,16 +942,22 @@ void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) {
     const MaybeAlign GAlign = G->getAlign();
 
     writeThunkOrAliasIfNeeded(F, G);
+    if (FEC)
+      NewF->setEntryCount(*FEC);
     writeThunkOrAliasIfNeeded(F, NewF);
 
     if (NewFAlign || GAlign)
       F->setAlignment(std::max(NewFAlign.valueOrOne(), GAlign.valueOrOne()));
     else
       F->setAlignment(std::nullopt);
     F->setLinkage(GlobalValue::PrivateLinkage);
+    mergeEntryCountsInto(F, FEC, GEC);
     ++NumDoubleWeak;
     ++NumFunctionsMerged;
   } else {
+    auto FEC = F->getEntryCount(/*AllowSynthetic=*/true);
----------------
alokkrsharma wrote:

I'll update.

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


More information about the llvm-commits mailing list