[llvm-commits] PR8753

Jakub Staszak kubastaszak at gmail.com
Wed Dec 8 02:27:04 PST 2010


Proposed patch for PR8753.


--- lib/Transforms/Scalar/MemCpyOptimizer.cpp	(revision 121189)
+++ lib/Transforms/Scalar/MemCpyOptimizer.cpp	(working copy)
@@ -674,6 +674,14 @@
   // other.
   if (M->getSource() != MDep->getDest() || MDep->isVolatile())
     return false;
+
+  // If dep instruction can be easily removed, don't bother. It also prevents
+  // from infinie calculation for:
+  //    memcpy(a <- a)
+  //    memcpy(b <- a)
+  // See: PR8753
+  if (MDep->getSource() == MDep->getDest())
+    return false;

   // Second, the length of the memcpy's must be the same, or the preceeding one
   // must be larger than the following one.


-- 
Jakub Staszak



More information about the llvm-commits mailing list