[Patch] Enable value forwarding for loads from calloc without intervening store
Philip Reames
listmail at philipreames.com
Wed May 28 09:34:23 PDT 2014
(I have no idea why this didn't get sent to the mailing list, but here's
the manual forward...)
Enable value forwarding for loads from calloc without intervening store
http://reviews.llvm.org/D3931
This change extends GVN to handle the following case:
%1 = tail call noalias i8* @calloc(i64 1, i64 4) #2
%2 = bitcast i8* %1 to i32*
; This load is trivially constant zero
%3 = load i32* %2, align 4
This is analogous to the handling for malloc in the same places. Malloc
returns undef, calloc returns a zero value. Note that it is correct to
return zero even for out of bounds geps since the result of such a gep
would be undefined.
I'm not entirely clear why this code lives in GVN rather than elsewhere;
I have chosen to simply extend the existing design.
Please note: I do not have commit access and will need someone to commit
this on my behalf.
Philip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: calloc-load-forward.diff
Type: text/x-patch
Size: 2159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140528/ddff20e9/attachment.bin>
More information about the llvm-commits
mailing list