[PATCH] D16337: [LibCallSimplifier] fold memset(malloc(x), 0, x) --> calloc(1, x)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 14:42:17 PST 2016


spatel updated the summary for this revision.
spatel updated this revision to Diff 45448.
spatel added a comment.

Patch updated: now with less ambition and more TODOs!

1. Restrict the optimization to hasOneUse() of the malloc. This isn't going to fire for most real code AFAICT because neither the llvm.memset() intrinsic nor the memset_chk() libcall cases will qualify. I don't know how to avoid the intermediate store problem noted by Chad yet, so take a baby step. Sorry PR25892.

2. The earlier draft added a DataLayout member to FortifiedLibCallSimplifier, but we can just pull that from the module and use it as needed. This way we don't have to change the constructor and affect unrelated code (CodeGenPrepare).

3. Fixed to make sure that calloc() exists and is available for the transform; if not, bail.


http://reviews.llvm.org/D16337

Files:
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  test/Transforms/InstCombine/memset-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16337.45448.patch
Type: text/x-patch
Size: 5225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160120/693e0a97/attachment.bin>


More information about the llvm-commits mailing list