[llvm-commits] [PATCH] InstCombine: remove malloc+free if malloc's only uses are comparisons to null

Matti Niemenmaa matti.niemenmaa+llvm at iki.fi
Wed May 19 05:07:28 PDT 2010


On 2010-05-17 14:07, Matti Niemenmaa wrote:
> The code in InstCombineCompares.cpp makes me wonder whether we should be
> operating on the malloc call to begin with? That is, move this 'malloc +
> [icmps] + [free]' removal from visitFree and InstCombineCompares.cpp to
> a new InstCombiner::visitMalloc function which would be called like
> visitFree currently is, from InstCombiner::visitCallInst.

I did this and the other mentioned changes: replacing the icmps directly 
instead of changing their operands and only working on icmp eq/ne 
instead of all kinds of icmp.

Updated patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: instcombine-mallocs-only-null-compared-against.patch
Type: text/x-patch
Size: 6787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100519/2e10eeb0/attachment.bin>


More information about the llvm-commits mailing list