diff options
author | David Green <david.green@arm.com> | 2025-08-19 10:37:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-19 10:37:17 +0100 |
commit | a7df02f83c74c7229a09b2f89a51b003075560ab (patch) | |
tree | ca07b562c02c152906c00834466057d5243a7ead /llvm/lib/Analysis/ValueTracking.cpp | |
parent | d286f2ef5578e8e6fb64fa00eefbec3c240063fb (diff) | |
download | llvm-a7df02f83c74c7229a09b2f89a51b003075560ab.zip llvm-a7df02f83c74c7229a09b2f89a51b003075560ab.tar.gz llvm-a7df02f83c74c7229a09b2f89a51b003075560ab.tar.bz2 |
[InstCombine] Make strlen optimization more resilient to different gep types. (#153623)
This makes the optimization in optimizeStringLength for strlen(gep
@glob, %x) -> sub endof@glob, %x a little more resilient, and maybe a
bit more correct for geps with non-array types.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 50e43a5..8ea3a03 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6356,27 +6356,6 @@ llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range, return nullptr; } -bool llvm::isGEPBasedOnPointerToString(const GEPOperator *GEP, - unsigned CharSize) { - // Make sure the GEP has exactly three arguments. - if (GEP->getNumOperands() != 3) - return false; - - // Make sure the index-ee is a pointer to array of \p CharSize integers. - // CharSize. - ArrayType *AT = dyn_cast<ArrayType>(GEP->getSourceElementType()); - if (!AT || !AT->getElementType()->isIntegerTy(CharSize)) - return false; - - // Check to make sure that the first operand of the GEP is an integer and - // has value 0 so that we are sure we're indexing into the initializer. - const ConstantInt *FirstIdx = dyn_cast<ConstantInt>(GEP->getOperand(1)); - if (!FirstIdx || !FirstIdx->isZero()) - return false; - - return true; -} - // If V refers to an initialized global constant, set Slice either to // its initializer if the size of its elements equals ElementSize, or, // for ElementSize == 8, to its representation as an array of unsiged |