This is an archive of the discontinued LLVM Phabricator instance.

[MemCpyOpt] Do not exchange llvm.lifetime.start and llvm.memcpy
ClosedPublic

Authored by timshen on Jun 7 2016, 10:48 AM.

Details

Summary

The transform:

llvm.lifetime.start(%tmp5)
llvm.lifetime.memcpy(%arg1, %tmp5)

->

llvm.lifeitme.memcpy(%arg1, %tmp5)
llvm.lifetime.start(%arg1)

is wrong, since then lifetime.start doesn't operate on an alloca, and lifetime.start and lifetime.end don't match anymore.

Diff Detail

Repository
rL LLVM

Event Timeline

timshen updated this revision to Diff 59913.Jun 7 2016, 10:48 AM
timshen retitled this revision from to [MemCpyOpt] Do not exchange llvm.lifetime.start and llvm.memcpy.
timshen updated this object.
timshen added a reviewer: iteratee.
timshen added a subscriber: llvm-commits.
timshen updated this object.Jun 7 2016, 11:27 AM
echristo added inline comments.Jun 7 2016, 11:28 AM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
792 ↗(On Diff #59913)

We might be able to move this check to line 1184 before we call the function... or maybe hoist the conditions a bit and handle it for processStore as well?

Thoughts?

timshen added inline comments.Jun 7 2016, 11:59 AM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
792 ↗(On Diff #59913)

It'll be hard to check this in a higher level, because the CallInst doesn't necessarily exist.

Checking at every caller side will also work, but I can't think of a case where we don't need this check - exchanging a lifetime mark with the memcpy is clearly wrong.

echristo added inline comments.Jun 7 2016, 2:49 PM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
792 ↗(On Diff #59913)

I was mostly trying to figure out other ways to get down here than where we are. I guess this will work though...

iteratee accepted this revision.Jun 7 2016, 3:44 PM
iteratee edited edge metadata.
This revision is now accepted and ready to land.Jun 7 2016, 3:44 PM
This revision was automatically updated to reflect the committed changes.