[PATCH] D88460: Strlen loop idiom recognition

Shawn Landden via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 16:15:24 PDT 2020


shawnl resigned from this revision.
shawnl added inline comments.
This revision now requires review to proceed.


================
Comment at: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp:1639
+
+  // The loop exit must be conditioned on an icmp with 0.
+  // The icmp operand has to be a load on some SSA reg that increments
----------------
efriedma wrote:
> shawnl wrote:
> > If the passed pointer has the "nonnull" attribute then this condition need not be present.
> The icmp isn't against a pointer; it's against an i8.  Or, it should be; I guess the code is missing a check that it's i8, as opposed to some arbitrary integer type.
> 
> For comparison, it's undefined behavior to call strlen with a null pointer.
My bad. I was really working from example code (and the tests also have a null check). This is why in my C code I always use '\x00' for NUL (the character) and not 0 or NULL.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88460/new/

https://reviews.llvm.org/D88460



More information about the llvm-commits mailing list