[PATCH] D32839: SimplifyLibCalls: Optimize wcslen

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 5 13:08:42 PDT 2017


MatzeB marked 4 inline comments as done.
MatzeB added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:3038
     // length of the string must be zero.
-    Str = "";
+    Index.Array = nullptr;
+    Index.Offset = 0;
----------------
efriedma wrote:
> Do we care about the size of the array in this case?
Looks like you answered your own question by digging out that PR in the next comment :)
That testcase is fixed as well in my latest revision.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:458
+             I < E; ++I) {
+          if (Index.Array->getElementAsInteger(I) == 0) {
+            NullTermIdx = I;
----------------
efriedma wrote:
> Could you use an iterator which returns the elements of the ConstantDataArray, instead of using explicit indexing everywhere?
There are no iterators defined for ConstantDataArray, did I miss something? (Defining them seems tricky to get right to support various datatypes and target/host data conversions).


Repository:
  rL LLVM

https://reviews.llvm.org/D32839





More information about the llvm-commits mailing list