[Analysis] Validate the return type of s(n)printf like libcalls
authorMartin Storsjo <martin@martin.st>
Fri, 11 May 2018 16:53:56 +0000 (16:53 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 11 May 2018 16:53:56 +0000 (16:53 +0000)
commit0d7c37756bc3609d9a1f3a9d9ba79842acca1e4a
tree0ce2147536de0d5c7f28091347558e152de810ad
parent458506871a0c5581497a19bc50fdd22f8ad9a911
[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
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/test/Transforms/InstCombine/sprintf-void.ll [new file with mode: 0644]