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

Richard Smith - zygoloid via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 14:23:16 PDT 2020


rsmith added inline comments.


================
Comment at: llvm/docs/LangRef.rst:12477-12478
-The '``llvm.memcpy.*``' intrinsics copy a block of memory from the
-source location to the destination location, which are not allowed to
-overlap. It copies "len" bytes of memory over. If the argument is known
-to be aligned to some boundary, this can be specified as an attribute on
----------------
I think we only want to allow the source and destination to be the same, and still want to disallow all other cases of overlap. We still want to be able to lower `llvm.memcpy` to `memcpy` not `memmove`.


================
Comment at: llvm/lib/Analysis/BasicAliasAnalysis.cpp:982
   // no-aliases the other.
   if (auto *Inst = dyn_cast<AnyMemCpyInst>(Call)) {
     AliasResult SrcAA, DestAA;
----------------
This would presumably now be correct for `memmove` too.


================
Comment at: llvm/lib/Analysis/BasicAliasAnalysis.cpp:989-994
+    if (SrcAA == MustAlias && DestAA == NoAlias)
       // Loc is exactly the memcpy source thus disjoint from memcpy dest.
       return ModRefInfo::Ref;
-    if ((DestAA = getBestAAResults().alias(MemoryLocation::getForDest(Inst),
-                                           Loc, AAQI)) == MustAlias)
+    if (DestAA == MustAlias && SrcAA == NoAlias)
       // The converse case.
       return ModRefInfo::Mod;
----------------
These two `if`s appear to now be equivalent to what would happen anyway in the general-case code below, and can presumably be deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86815



More information about the llvm-commits mailing list