summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/TargetLibraryInfo.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-11 16:53:56 +0000
committerMartin Storsjo <martin@martin.st>2018-05-11 16:53:56 +0000
commit0d7c37756bc3609d9a1f3a9d9ba79842acca1e4a (patch)
tree0ce2147536de0d5c7f28091347558e152de810ad /llvm/lib/Analysis/TargetLibraryInfo.cpp
parent458506871a0c5581497a19bc50fdd22f8ad9a911 (diff)
downloadbcm5719-llvm-0d7c37756bc3609d9a1f3a9d9ba79842acca1e4a.tar.gz
bcm5719-llvm-0d7c37756bc3609d9a1f3a9d9ba79842acca1e4a.zip
[Analysis] Validate the return type of s(n)printf like libcalls
If the sprintf function is static (as on mingw-w64, where many stdio functions are static inline wrappers), earlier optimization passes could optimize out the return value altogether, and make it void, which could break optimizations of this libcall that touch the return value. This fixes the issue discussed in PR37408 for the sprintf function. Differential Revision: https://reviews.llvm.org/D46752 llvm-svn: 332106
Diffstat (limited to 'llvm/lib/Analysis/TargetLibraryInfo.cpp')
-rw-r--r--llvm/lib/Analysis/TargetLibraryInfo.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index ff6aae8b5ec..e0f7e1b5822 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -692,10 +692,12 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
case LibFunc_siprintf:
case LibFunc_sprintf:
return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
- FTy.getParamType(1)->isPointerTy());
+ FTy.getParamType(1)->isPointerTy() &&
+ FTy.getReturnType()->isIntegerTy(32));
case LibFunc_snprintf:
return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
- FTy.getParamType(2)->isPointerTy());
+ FTy.getParamType(2)->isPointerTy() &&
+ FTy.getReturnType()->isIntegerTy(32));
case LibFunc_setitimer:
return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
FTy.getParamType(2)->isPointerTy());
OpenPOWER on IntegriCloud