[PATCH] D135261: [SimplifyLibCalls] Remove invalid code comment in optimizeStringLength. NFC

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 05:43:46 PDT 2022


bjope created this revision.
bjope added a reviewer: MatzeB.
Herald added a subscriber: hiraditya.
Herald added a project: All.
bjope requested review of this revision.
Herald added a project: LLVM.

The limitation in LibCallSimplifier::optimizeStringLength to only
optimize when the string is an i8 array was removed already in
commit 50ec0b5dceff1f3fe93 back in 2017. Drop the comment as it
isn't valid any longer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135261

Files:
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp


Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -925,11 +925,6 @@
   // If s is a constant pointer pointing to a string literal, we can fold
   // strlen(s + x) to strlen(s) - x, when x is known to be in the range
   // [0, strlen(s)] or the string has a single null terminator '\0' at the end.
-  // We only try to simplify strlen when the pointer s points to an array
-  // of i8. Otherwise, we would need to scale the offset x before doing the
-  // subtraction. This will make the optimization more complex, and it's not
-  // very useful because calling strlen for a pointer of other types is
-  // very uncommon.
   if (GEPOperator *GEP = dyn_cast<GEPOperator>(Src)) {
     // TODO: Handle subobjects.
     if (!isGEPBasedOnPointerToString(GEP, CharSize))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135261.465354.patch
Type: text/x-patch
Size: 941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/e30657db/attachment.bin>


More information about the llvm-commits mailing list