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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 19 15:11:21 PDT 2021


lebedev.ri added a comment.

I think i see where this is going - the just-`malloc`ed, but never touched memory
doesn't need to be actually backed by an actual pages (see overcommit),
while i guess `calloc` doesn't just mark the pages as zeroed-out,
but actually marks them dirty and needed to be allocated,
at least not unless you happen to allocate in multiple of pages?

I guess the easy fix here is to require that `memset` post-dominates the `malloc`,
but i guess we also need some langref blurb about this,
because the transformation is correct, just-`malloc`ed memory is filed with `undef`,
which we can always define into zeros: https://alive2.llvm.org/ce/z/C4vWH2


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