# Similar Function Merging

**URL:** <https://discourse.llvm.org/t/similar-function-merging/56780>\
**Category:** LLVM Dev List Archives\
**Created:** [October 26, 2020, 11:28pm UTC](https://discourse.llvm.org/t/similar-function-merging/56780 "2020-10-26T23:28:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evodius96](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/evodius96/32/16784_2.png) [@evodius96](https://discourse.llvm.org/u/evodius96)\
**Post date:** [October 26, 2020, 11:28pm UTC](https://discourse.llvm.org/t/similar-function-merging/56780/1 "2020-10-26T23:28:29Z")

</div>

Hello! I heard “similar function merging” discussed at the Developers’ Meeting a couple of weeks ago, and I wanted to look into this more for potential code size reduction as it focused on merging functions with small differences rather than identical function merging.

Is [https://reviews.llvm.org/D85616](https://reviews.llvm.org/D85616) the latest review for this pass? Any ideas on when it will be able to be upstreamed?

Can this pass be run even when –ffunction-sections is enabled? Also, I understand this pass is most useful during LTO, when there is better knowledge as to the functions that are kept in the final link.

Thanks!

-Alan Phipps

---

<div class="post-metadata">

**Author:** ![hiraditya](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/hiraditya/32/1445_2.png) [@hiraditya](https://discourse.llvm.org/u/hiraditya)\
**Post date:** [October 27, 2020, 4:47am UTC](https://discourse.llvm.org/t/similar-function-merging/56780/2 "2020-10-27T04:47:18Z")

</div>

Hi Alan,  
Here are the patches that port merge similar functions to the ThinLTO

-[https://reviews.llvm.org/D52896](https://reviews.llvm.org/D52896)  
-[https://reviews.llvm.org/D52898](https://reviews.llvm.org/D52898)  
-[https://reviews.llvm.org/D52966](https://reviews.llvm.org/D52966)  
-[https://reviews.llvm.org/D53253](https://reviews.llvm.org/D53253)  
-[https://reviews.llvm.org/D53254](https://reviews.llvm.org/D53254)

Before merging the patches we wanted to improve the comparison of IR Types. That project started in the GSoC this year and the patch to improve comparison or IR Types is posted by Vishal:

[https://reviews.llvm.org/D82892](https://reviews.llvm.org/D82892)

-Aditya
