[PATCH] D45344: [InstCombine] Fold malloc + memset to calloc even for llvm.memset

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 09:23:57 PDT 2018


spatel added a comment.

IIUC, these are 2 independent changes, so they should be split into separate patches:

1. Handle the memset intrinsic identically to the way we handle the memset libcall. What about memset_chk()?
2. Remove the hasOneUse() limitation on the malloc. The reason that's there is discussed in https://reviews.llvm.org/D16337 - the transform must be made safe from intermediate stores. This patch as-is will miscompile that pattern.

I've added tests at https://reviews.llvm.org/rL329412 and regenerated the check lines. Please fix/limit this patch and rebase.


https://reviews.llvm.org/D45344





More information about the llvm-commits mailing list