[PATCH] D32837: TargetLibraryInfo: Introduce wcslen

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 13:17:05 PDT 2017


MatzeB updated this revision to Diff 97870.
MatzeB added a comment.

- Add missing wcslen declaration to unittests/Analysis/TargetLibraryInfoTest.cpp


Repository:
  rL LLVM

https://reviews.llvm.org/D32837

Files:
  include/llvm/Analysis/TargetLibraryInfo.def
  lib/Analysis/TargetLibraryInfo.cpp
  lib/Transforms/Utils/BuildLibCalls.cpp
  unittests/Analysis/TargetLibraryInfoTest.cpp


Index: unittests/Analysis/TargetLibraryInfoTest.cpp
===================================================================
--- unittests/Analysis/TargetLibraryInfoTest.cpp
+++ 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.
Index: lib/Transforms/Utils/BuildLibCalls.cpp
===================================================================
--- lib/Transforms/Utils/BuildLibCalls.cpp
+++ 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: lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- lib/Analysis/TargetLibraryInfo.cpp
+++ 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: include/llvm/Analysis/TargetLibraryInfo.def
===================================================================
--- include/llvm/Analysis/TargetLibraryInfo.def
+++ 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")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32837.97870.patch
Type: text/x-patch
Size: 2155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170504/b4bec67a/attachment.bin>


More information about the llvm-commits mailing list