[PATCH] D123817: [InstCombine] Fold strnlen of constant strings.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 13:07:38 PDT 2022


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LG



================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:655
+  if (uint64_t Len = GetStringLength(Src, CharSize)) {
+    Value *Min = ConstantInt::get(CI->getType(), Len - 1);
+    // Fold strlen("xyz") -> 3 and strnlen("xyz", 2) -> 2
----------------
The `Min` name doesn't really make sense to me here -- if anything, this is a max. I'd call this `LenC` or maybe `LenWithoutNull` to highlight where the `-1` comes from.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123817



More information about the llvm-commits mailing list