[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 08:40:32 PST 2016
spatel added a comment.
In http://reviews.llvm.org/D16337#331118, @mcrosier wrote:
> What happens if there's an intervening store to the malloc'ed memory? (dumb I know.. but..)
Ah, good catch. I checked 'hasOneUse()' in an earlier draft of this to avoid that scenario, but then I noticed that the example in the bug report had that 'llvm.objectsize' and other uses between the malloc and memset, so I removed that condition. I need to find a way around that.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:978
@@ +977,3 @@
+ B, DL, TLI);
+ Malloc->replaceAllUsesWith(Calloc);
+ Malloc->eraseFromParent();
----------------
mcrosier wrote:
> Shouldn't you check that Calloc is non-null here?
Yes - that won't work if calloc doesn't exist for the target.
http://reviews.llvm.org/D16337
More information about the llvm-commits
mailing list