This change will shorten memset if the beginning of memset is overwritten by later stores.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
The patch looks to be in good shape generally. I've inlined a few nits and questions/suggestions.
| lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
|---|---|---|
| 278 ↗ | (On Diff #53067) | The preferred doxygen style is to drop the function name in the comments. |
| 300 ↗ | (On Diff #53067) | The preferred doxygen style is to drop the function name in the comments. |
| 303 ↗ | (On Diff #53067) | Once this gets committed please file a PR unless you plan on doing the follow up work. |
| 348 ↗ | (On Diff #53067) | location. -> location, |
| 429 ↗ | (On Diff #53067) | The other interesting case -> Another interesting case |
| 442 ↗ | (On Diff #53067) | We also need -> Finally, we also need |
| 452 ↗ | (On Diff #53067) | 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 ↗ | (On Diff #53067) | I believe you dropped a comment: // Otherwise, they don't completely overlap. |
| test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
| 3 ↗ | (On Diff #53067) | 4to8 -> 4to7? |
| 16 ↗ | (On Diff #53067) | 0to4 -> 0to3? Should you decide to make this change, more instances below.. |
| 52 ↗ | (On Diff #53067) | 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). |
Thanks Chad for the review. I will address your comments soon.
| lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
|---|---|---|
| 303 ↗ | (On Diff #53067) | Yes, I will do that. |
| 452 ↗ | (On Diff #53067) | 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 ↗ | (On Diff #53067) | Oh.. Thanks .. |
| test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
| 16 ↗ | (On Diff #53067) | Thanks, I will fix them. |
| 52 ↗ | (On Diff #53067) | Okay, I will comment it. |
| lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
|---|---|---|
| 341 ↗ | (On Diff #53067) | It's better to list the enum members alphabetically. |
| 639 ↗ | (On Diff #53067) | Enclosing the RHS in parentheses makes it more readable. |
| 656 ↗ | (On Diff #53067) | Parentheses not really needed: DepLoc.Size - (InstWriteOffset - DepWriteOffset) equals DepLoc.Size - InstWriteOffset - DepWriteOffset |
Addressed Mandeep's comments. Thanks for the review.
| lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
|---|---|---|
| 656 ↗ | (On Diff #53067) | DepLoc.Size - (InstWriteOffset - DepWriteOffset) is same as DepLoc.Size - InstWriteOffset + DepWriteOffset, but I think DepLoc.Size - (InstWriteOffset - DepWriteOffset) is more readable. |
LGTM, assuming my minor nits are addressed.
| lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
|---|---|---|
| 289 ↗ | (On Diff #54263) | Any particular reason we don't support memmove? Maybe add a FIXME if it's safe to transform memmove. |
| 303 ↗ | (On Diff #54263) | Supporting memcpy/memmove should... |
| 430 ↗ | (On Diff #54263) | Please add a period. |
| 658 ↗ | (On Diff #54263) | I agree with Jun on this one. |