$OpenBSD: patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp,v 1.1 2017/02/26 13:34:23 ajacoutot Exp $

Disable loop idiom recognition for _libc_memset and _libc_memcpy.  These are
the internal names we use in libc for memset and memcpy and having the
compiler optimize them as calls to memset and memcpy will lead to infinite
recursion.

--- lib/Transforms/Scalar/LoopIdiomRecognize.cpp.orig	Sat Feb 25 12:12:05 2017
+++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp	Sat Feb 25 13:03:56 2017
@@ -231,6 +231,8 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) {
   StringRef Name = L->getHeader()->getParent()->getName();
   if (Name == "memset" || Name == "memcpy")
     return false;
+  if (Name == "_libc_memset" || Name == "_libc_memcpy")
+    return false;
 
   // Determine if code size heuristics need to be applied.
   ApplyCodeSizeHeuristics =
