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

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 7 11:14:32 PDT 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/IPO/MergeFunctions.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/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 4d2db145d..95f9b294e 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -882,7 +882,7 @@ static bool isODR(const Function *F) {
 /// This follows Function::getImportGUIDs(), which reads import GUID operands
 /// from function_entry_count metadata.
 static DenseSet<GlobalValue::GUID> unionImportGUIDs(const Function *F,
-                                                   const Function *G) {
+                                                    const Function *G) {
   DenseSet<GlobalValue::GUID> All = F->getImportGUIDs();
   DenseSet<GlobalValue::GUID> GImports = G->getImportGUIDs();
   All.insert(GImports.begin(), GImports.end());
@@ -895,12 +895,13 @@ static DenseSet<GlobalValue::GUID> unionImportGUIDs(const Function *F,
 /// If either function carries a synthetic count, the result is synthetic.
 ///
 /// If `Imports` is provided it should point to the union of import GUIDs from
-/// both source functions; it will be passed through to `Function::setEntryCount`
-/// so that SamplePGO/ThinLTO import information is preserved.
-static void mergeEntryCountsInto(
-    Function *F, std::optional<Function::ProfileCount> FC,
-    std::optional<Function::ProfileCount> GC,
-    const DenseSet<GlobalValue::GUID> *Imports = nullptr) {
+/// both source functions; it will be passed through to
+/// `Function::setEntryCount` so that SamplePGO/ThinLTO import information is
+/// preserved.
+static void
+mergeEntryCountsInto(Function *F, std::optional<Function::ProfileCount> FC,
+                     std::optional<Function::ProfileCount> GC,
+                     const DenseSet<GlobalValue::GUID> *Imports = nullptr) {
   if (!FC && !GC)
     return;
   // Match the saturating-add convention used for profile count accumulation

``````````

</details>


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


More information about the llvm-commits mailing list