[llvm-commits] [PATCH] simplify-libcalls: fold strstr(a, b) == a -> strncmp(a, b, strlen(b)) == 0

Benjamin Kramer benny.kra at googlemail.com
Tue Jun 15 11:50:59 PDT 2010


This seems to be a common idiom to check the prefix of a string (lldb uses it) and it triggers O(n*m) behavior in most libc implementations. strncmp brings it down to O(m).

I'm not sure if simplify-libcalls is the right place for this. The code basically works around the pass's infrastructure (skipping statistics etc.)


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


More information about the llvm-commits mailing list