[llvm-commits] [llvm] r135286 - /llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Chad Rosier mcrosier at apple.com
Fri Jul 15 11:25:04 PDT 2011


Author: mcrosier
Date: Fri Jul 15 13:25:04 2011
New Revision: 135286

URL: http://llvm.org/viewvc/llvm-project?rev=135286&view=rev
Log:
Disable loop idiom recognition of memset/memcpy if the function being compiled
is named after a common idiom (i.e., memset/memcpy).  Otherwise, we can run into 
infinite recursion.  Ideally, the user should use the correct -fno-builtin flag,
but in case they don't we should play nicely.
rdar://9763412

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=135286&r1=135285&r2=135286&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Fri Jul 15 13:25:04 2011
@@ -173,6 +173,11 @@
 bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
   CurLoop = L;
 
+  // Disable loop idiom recognition if the function's name is a common idiom. 
+  StringRef Name = L->getHeader()->getParent()->getName();
+  if (Name == "memset" || Name == "memcpy")
+    return false;
+
   // The trip count of the loop must be analyzable.
   SE = &getAnalysis<ScalarEvolution>();
   if (!SE->hasLoopInvariantBackedgeTakenCount(L))





More information about the llvm-commits mailing list