Index: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def =================================================================== --- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def +++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def @@ -1115,6 +1115,9 @@ /// int vsscanf(const char *s, const char *format, va_list arg); TLI_DEFINE_ENUM_INTERNAL(vsscanf) TLI_DEFINE_STRING_INTERNAL("vsscanf") +/// size_t wcslen (const wchar_t* wcs); +TLI_DEFINE_ENUM_INTERNAL(wcslen) +TLI_DEFINE_STRING_INTERNAL("wcslen") /// ssize_t write(int fildes, const void *buf, size_t nbyte); TLI_DEFINE_ENUM_INTERNAL(write) TLI_DEFINE_STRING_INTERNAL("write") Index: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp +++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp @@ -1176,6 +1176,10 @@ FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1) == SizeTTy && FTy.getParamType(2) == SizeTTy); + case LibFunc_wcslen: + return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && + FTy.getReturnType()->isIntegerTy()); + case LibFunc::NumLibFuncs: break; } Index: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp @@ -113,6 +113,7 @@ bool Changed = false; switch (TheLibFunc) { case LibFunc_strlen: + case LibFunc_wcslen: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 0); Index: llvm/trunk/unittests/Analysis/TargetLibraryInfoTest.cpp =================================================================== --- llvm/trunk/unittests/Analysis/TargetLibraryInfoTest.cpp +++ llvm/trunk/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -334,6 +334,7 @@ "declare i32 @vsnprintf(i8*, i64, i8*, %struct*)\n" "declare i32 @vsprintf(i8*, i8*, %struct*)\n" "declare i32 @vsscanf(i8*, i8*, %struct*)\n" + "declare i64 @wcslen(i32*)\n" // These functions were also extracted from the OS X headers, but they are // available with a special name on darwin.