[PATCH] D32839: SimplifyLibCalls: Optimize wcslen

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 11:34:10 PDT 2017


efriedma added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:532
+  assert(IntTy->isIntegerTy());
+  unsigned CharSize = IntTy->getIntegerBitWidth();
+
----------------
Making assumptions about the implementation of wcslen() based on the type of the pointer is bad idea.  It probably works most of the time for code generated by clang, but pointee types don't have any semantics in IR, so it's likely to mess up at some point.  (Also, pointee types in IR are likely to go away at some point in the future.)

I think the right approach is to add a function to TargetLibraryInfo to compute the size of wchar_t based on the triple.


Repository:
  rL LLVM

https://reviews.llvm.org/D32839





More information about the llvm-commits mailing list