[llvm] Support non-malloc functions in malloc+memset->calloc fold (PR #138299)

Andrew Pinski via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 19:06:49 PDT 2025


pinskia wrote:

> > I think it is worth it because there are some programs out there that use xmalloc and it might be useful to optimize that to xcalloc.
> 
> Sorry, I'm not sure I understand this. I think the original question is about extending the system to be smart enough to transform `alloc(size)` to `calloc(1, size)`. Whereas `xmalloc`->`xcalloc` can be easily done by a frontend, and just requires adding `"alloc-variant-zeroed"="xcalloc"` to `xmalloc`.

xcalloc still takes the same arguments as calloc. Likewise of xmalloc.
So it is similar in nature to malloc->calloc transformation. 

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


More information about the llvm-commits mailing list