llvm-project
fb20f9f6 - [MergeFunctions] Preserve entry counts on folds (#202218)

Commit
9 days ago
[MergeFunctions] Preserve entry counts on folds (#202218) **Summary** `MergeFunctions` can fold equivalent functions into a single retained implementation. When that happens, the retained body may be reached by callers of both original functions, but its `function_entry_count` metadata previously preserved only one side of the profile data. For example, folding functions with entry counts `2000` and `1000` could leave the retained body with only `2000`. This patch updates the retained implementation after a successful merge, so the entry count becomes `3000`, using saturating add. For ODR/double-thunk merges, the private backing body gets the combined count while the thunks keep their own entry counts. For alias-backed merges, the backing function carries the combined count. **AI Assistance Disclosure** AI tools were used to browse the LLVM codebase and explore test-case variations. All outputs were manually reviewed and validated, and I take full responsibility for the final changes.
Author
Parents
Loading