This is an archive of the discontinued LLVM Phabricator instance.

[DeadStoreElimination] Shorten beginning of memset overwritten by later stores
ClosedPublic

Authored by junbuml on Apr 8 2016, 1:03 PM.

Diff Detail

Event Timeline

junbuml updated this revision to Diff 53067.Apr 8 2016, 1:03 PM
junbuml retitled this revision from to [DeadStoreElimination] Shorten beginning of memset overwritten by later stores.
junbuml updated this object.
junbuml added a subscriber: llvm-commits.

Kindly ping

mcrosier requested changes to this revision.Apr 19 2016, 1:11 PM
mcrosier edited edge metadata.

The patch looks to be in good shape generally. I've inlined a few nits and questions/suggestions.

lib/Transforms/Scalar/DeadStoreElimination.cpp
278

The preferred doxygen style is to drop the function name in the comments.

300

The preferred doxygen style is to drop the function name in the comments.

303

Once this gets committed please file a PR unless you plan on doing the follow up work.

348

location. -> location,

429

The other interesting case -> Another interesting case

442

We also need -> Finally, we also need

452

I suspect this condition 'int64_t(LaterOff + Later.Size) < int64_t(EarlierOff + Earlier.Size)' will always be true because the OverwriteComplete case will return true when LaterEnd is >= EarlyEnd.

If I am correct and the condition is true, perhaps add an assert that it's always true.

454

I believe you dropped a comment:

// Otherwise, they don't completely overlap.
test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll
3

4to8 -> 4to7?

16

0to4 -> 0to3?

Should you decide to make this change, more instances below..

52

Perhaps add a comments stating why this transformation is unsafe (i.e., we must not change the alignment of the earlier write, if I'm not mistaken).

This revision now requires changes to proceed.Apr 19 2016, 1:11 PM

Thanks Chad for the review. I will address your comments soon.

lib/Transforms/Scalar/DeadStoreElimination.cpp
303

Yes, I will do that.

452

Agree. If the first two condition is true and the the third condition is false, that means OverwriteComplete. As you pointed, the third condition could be an assert().

454

Oh.. Thanks ..

test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll
16

Thanks, I will fix them.

52

Okay, I will comment it.

mgrang added a subscriber: mgrang.Apr 19 2016, 1:30 PM
mgrang added inline comments.
lib/Transforms/Scalar/DeadStoreElimination.cpp
341

It's better to list the enum members alphabetically.

639

Enclosing the RHS in parentheses makes it more readable.
bool IsOverwriteEnd = (OR == OverwriteEnd);

656

Parentheses not really needed:

DepLoc.Size - (InstWriteOffset - DepWriteOffset) equals DepLoc.Size - InstWriteOffset - DepWriteOffset

junbuml updated this revision to Diff 54256.Apr 19 2016, 1:59 PM
junbuml edited edge metadata.

Addressed Chad's comments.

junbuml updated this revision to Diff 54263.Apr 19 2016, 2:40 PM
junbuml edited edge metadata.

Addressed Mandeep's comments. Thanks for the review.

lib/Transforms/Scalar/DeadStoreElimination.cpp
656

DepLoc.Size - (InstWriteOffset - DepWriteOffset) is same as DepLoc.Size - InstWriteOffset + DepWriteOffset, but I think DepLoc.Size - (InstWriteOffset - DepWriteOffset) is more readable.

mcrosier accepted this revision.Apr 20 2016, 7:58 AM
mcrosier edited edge metadata.

LGTM, assuming my minor nits are addressed.

lib/Transforms/Scalar/DeadStoreElimination.cpp
289

Any particular reason we don't support memmove? Maybe add a FIXME if it's safe to transform memmove.

303

Supporting memcpy/memmove should...

431

Please add a period.

656

I agree with Jun on this one.

This revision is now accepted and ready to land.Apr 20 2016, 7:58 AM
junbuml updated this revision to Diff 54655.Apr 22 2016, 8:11 AM
junbuml edited edge metadata.

Addressed Chad's comments. Thanks for reviewing this.

This revision was automatically updated to reflect the committed changes.