summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-09-26 02:36:57 +0000
committerMatthias Braun <matze@braunis.de>2017-09-26 02:36:57 +0000
commitcc603ee3d563ca2ae27fb7bf439602a415a91268 (patch)
tree873d87913405069b5f3754cdb59945e761753820 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
parentf2c83670f712c67b419fdb03f848e2cfb4e4c918 (diff)
downloadbcm5719-llvm-cc603ee3d563ca2ae27fb7bf439602a415a91268.tar.gz
bcm5719-llvm-cc603ee3d563ca2ae27fb7bf439602a415a91268.zip
TargetLibraryInfo: Stop guessing wchar_t size
Usually the frontend communicates the size of wchar_t via metadata and we can optimize wcslen (and possibly other calls in the future). In cases without the wchar_size metadata we would previously try to guess the correct size based on the target triple; however this is fragile to keep up to date and may miss users manually changing the size via flags. Better be safe and stop guessing and optimizing if the frontend didn't communicate the size. Differential Revision: https://reviews.llvm.org/D38106 llvm-svn: 314185
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 37cfc2cbbc1..22c078a8d2f 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -508,6 +508,9 @@ Value *LibCallSimplifier::optimizeStrLen(CallInst *CI, IRBuilder<> &B) {
Value *LibCallSimplifier::optimizeWcslen(CallInst *CI, IRBuilder<> &B) {
Module &M = *CI->getParent()->getParent()->getParent();
unsigned WCharSize = TLI->getWCharSize(M) * 8;
+ // We cannot perform this optimization without wchar_size metadata.
+ if (WCharSize == 0)
+ return nullptr;
return optimizeStringLength(CI, B, WCharSize);
}
OpenPOWER on IntegriCloud