[PATCH] Allow call-slop optzn for destinations with a suitable dereferenceable attribute

Björn Steinbrink bsteinbr at gmail.com
Thu Oct 16 12:43:12 PDT 2014


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:637
@@ -636,5 +636,3 @@
   } else if (Argument *A = dyn_cast<Argument>(cpyDest)) {
-    // If the destination is an sret parameter then only accesses that are
-    // outside of the returned struct type can trap.
-    if (!A->hasStructRetAttr())
-      return false;
+    if (A->getDereferenceableBytes() < srcSize) {
+      // If the destination is an sret parameter then only accesses that are
----------------
hfinkel wrote:
> But if you do it this way you're now *requiring* the dereferenceable attribute, and we don't want to do that.
> 
> What you want to do is keep the existing logic for sret, and just add additional support for dereferenceable.
How so? The new check just skips the sret check if we already know that we have enough deferenceable bytes.

If there is no dereferenceable attribute, getDereferenceableBytes() returns 0, which is < srcSize and so we do the sret check, and only if that fails, false is returned.

http://reviews.llvm.org/D5832






More information about the llvm-commits mailing list