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
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 2be5d5ca..47a84bd 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1519,20 +1519,11 @@
return *Impl;
}
-unsigned TargetLibraryInfoImpl::getTargetWCharSize(const Triple &T) {
- // See also clang/lib/Basic/Targets.cpp.
- if (T.isPS4() || T.isOSWindows() || T.isArch16Bit())
- return 2;
- if (T.getArch() == Triple::xcore)
- return 1;
- return 4;
-}
-
unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
M.getModuleFlag("wchar_size")))
return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
- return getTargetWCharSize(Triple(M.getTargetTriple()));
+ return 0;
}
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()