Page MenuHomePhabricator

Enable value forwarding for loads from calloc without intervening store
ClosedPublic

Authored by reames on May 27 2014, 5:01 PM.

Details

Reviewers
reames
nlewycky
Summary

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.

Diff Detail

Event Timeline

reames updated this revision to Diff 9851.May 27 2014, 5:01 PM
reames retitled this revision from to Enable value forwarding for loads from calloc without intervening store.
reames updated this object.
reames edited the test plan for this revision. (Show Details)
reames added a reviewer: deleted.
reames added a reviewer: nlewycky.
reames updated this revision to Diff 9852.May 27 2014, 5:03 PM

Adding context for change to make review easier

reames removed a reviewer: deleted.May 27 2014, 5:07 PM
reames added a subscriber: Unknown Object (MLST).
reames updated this revision to Diff 9888.May 28 2014, 1:28 PM

Fixing review comments from Duncan Smith sent via email. Whitespace and commenting changes

reames accepted this revision.Jun 17 2014, 4:10 PM
reames added a reviewer: reames.

Closed via commit 210828

This revision is now accepted and ready to land.Jun 17 2014, 4:10 PM
reames closed this revision.Jun 17 2014, 4:12 PM