[llvm-commits] [PATCH] implement strncat and strncpy optimizations

Benjamin Kramer benny.kra at googlemail.com
Sat Apr 11 07:17:11 PDT 2009


This patch adds optimizations for the library functions strncpy and  
strncat to the simplify-libcalls pass.

The strcat and strncat opts share some code. I've implemented this by  
putting the common code in a method of StrCatOpt and made StrNCatOpt a  
subclass of StrCatOpt.

I've also factored out EmitMemSet from MemSetOpt so it can be reused  
by the strncpy opt.

  lib/Transforms/Scalar/SimplifyLibCalls.cpp  |  136 ++++++++++++++++++ 
+++++-----
  test/Transforms/SimplifyLibCalls/StrNCat.ll |   27 +++++
  test/Transforms/SimplifyLibCalls/StrNCpy.ll |   25 +++++
  3 files changed, 166 insertions(+), 22 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: strnopt.patch
Type: application/octet-stream
Size: 10636 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090411/b1cb345f/attachment.obj>
-------------- next part --------------



More information about the llvm-commits mailing list