[llvm] 0db4b1d - [SimplifyLibCalls] Adjust code comment in optimizeStringLength. NFC

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 11:00:57 PDT 2022


Author: Bjorn Pettersson
Date: 2022-10-06T20:00:27+02:00
New Revision: 0db4b1d1a873d8dc7f6fc312ae37fe15631dd037

URL: https://github.com/llvm/llvm-project/commit/0db4b1d1a873d8dc7f6fc312ae37fe15631dd037
DIFF: https://github.com/llvm/llvm-project/commit/0db4b1d1a873d8dc7f6fc312ae37fe15631dd037.diff

LOG: [SimplifyLibCalls] Adjust code comment in optimizeStringLength. NFC

The limitation in LibCallSimplifier::optimizeStringLength to only
optimize when the string is an i8 array was changed already in
commit 50ec0b5dceff1f3fe93 back in 2017.

We still only simplify when 's' points at an array of 'CharSize', so
the comment is still valid in the sense that we do not support
arbitrary array types.

Differential Revision: https://reviews.llvm.org/D135261

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index be0912b786009..1b6d39472be03 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -927,9 +927,9 @@ Value *LibCallSimplifier::optimizeStringLength(CallInst *CI, IRBuilderBase &B,
   // 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
+  // of CharSize elements. 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.


        


More information about the llvm-commits mailing list