[PATCH] D103009: [DSE] Transform memset + malloc --> calloc (PR25892)

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 03:27:12 PDT 2021


yurai007 added a comment.

I played a little bit with patch and checked how it performs with GCC unit tests added together with similar change in GCC on 2014.

In first case: https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/calloc-1.c malloc is transformed to calloc like for GCC which is good. 
In LLVM case on assembly level register pressure is very similar to GCC (especially for f() function) which means that issue mentioned by Haneef in PR discussion 
(https://bugs.llvm.org/show_bug.cgi?id=25892#c1) seems to be mitigated now.

However the second C++-like case: https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/g++.dg/tree-ssa/calloc.C is not transformed.  
Here CFG is more complex and I guess that DSE simply doesn't detect malloc - memset pair because they aren't in neighboring blocks. 
Apparently there is still room for improvements but let's leave it for future patches :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103009/new/

https://reviews.llvm.org/D103009



More information about the llvm-commits mailing list