diff options
| author | Matthias Braun <matze@braunis.de> | 2017-05-19 22:37:09 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2017-05-19 22:37:09 +0000 |
| commit | 50ec0b5dceff1f3fe9379580bc64480957a6ff83 (patch) | |
| tree | 92e8dfee8c92b4b3c68b2688d6d3969bc66a6028 /llvm/lib/IR | |
| parent | 89f3bcf0b526ebc0ebee949554c3f9b5bd199182 (diff) | |
| download | bcm5719-llvm-50ec0b5dceff1f3fe9379580bc64480957a6ff83.tar.gz bcm5719-llvm-50ec0b5dceff1f3fe9379580bc64480957a6ff83.zip | |
SimplifyLibCalls: Optimize wcslen
Refactor the strlen optimization code to work for both strlen and wcslen.
This especially helps with programs in the wild where people pass
L"string"s to const std::wstring& function parameters and the wstring
constructor gets inlined.
This also fixes a lingerind API problem/bug in getConstantStringInfo()
where zeroinitializers would always give you an empty string (without a
length) back regardless of the actual length of the initializer which
did not work well in the TrimAtNul==false causing the PR mentioned
below.
Note that the fixed getConstantStringInfo() needed fixes to SelectionDAG
memcpy lowering and may lead to some cases for out-of-bounds
zeroinitializer accesses not getting optimized anymore. So some code
with UB may produce out of bound memory reads now instead of just
producing zeros.
The refactoring "accidentally" fixes http://llvm.org/PR32124
Differential Revision: https://reviews.llvm.org/D32839
llvm-svn: 303461
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/Constants.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index f0b9dfb2d62..8b0ff66334a 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2616,8 +2616,8 @@ Constant *ConstantDataSequential::getElementAsConstant(unsigned Elt) const { return ConstantInt::get(getElementType(), getElementAsInteger(Elt)); } -bool ConstantDataSequential::isString() const { - return isa<ArrayType>(getType()) && getElementType()->isIntegerTy(8); +bool ConstantDataSequential::isString(unsigned CharSize) const { + return isa<ArrayType>(getType()) && getElementType()->isIntegerTy(CharSize); } bool ConstantDataSequential::isCString() const { |

