[PATCH] D86815: [LangRef] Remove non-overlapping guarantee from memcpy.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 09:50:39 PDT 2020


fhahn updated this revision to Diff 288970.
fhahn added a comment.

Update to only allow operands to exactly overlap or not at all, as suggested. Simplified AA code.

In D86815#2245481 <https://reviews.llvm.org/D86815#2245481>, @rsmith wrote:

> In D86815#2245467 <https://reviews.llvm.org/D86815#2245467>, @arsenm wrote:
>
>> In D86815#2245466 <https://reviews.llvm.org/D86815#2245466>, @arsenm wrote:
>>
>>> Why would we change this? What's the point of having separate memcpy and memmove intrinsics?
>>
>> I'm reading this as clang mis-uses llvm.memcpy when it probably should be using llvm.memmove
>
> There is a longstanding assumption made by ~every compiler that `memcpy(p, p, n)` is safe. That's what we should be encoding here. We should not be removing all overlap restrictions.

Sounds good to me! I don't think allowing exact overlap is really helpful in terms of AA (because it means the operands either Must or No-Alias), but it might be helpful for a more efficient lowering/implementation of memcpy.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86815/new/

https://reviews.llvm.org/D86815

Files:
  llvm/docs/LangRef.rst
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/test/Analysis/BasicAA/assume.ll
  llvm/test/Analysis/BasicAA/cs-cs.ll
  llvm/test/Analysis/BasicAA/guards.ll
  llvm/test/Analysis/MemorySSA/basicaa-memcpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-and-memcpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/simple.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86815.288970.patch
Type: text/x-patch
Size: 17258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200831/1c897bf5/attachment-0001.bin>


More information about the llvm-commits mailing list