[llvm] r332087 - [APFloat] Set losesInfo on no-op convert
Sven van Haastregt via llvm-commits
llvm-commits at lists.llvm.org
Fri May 11 02:45:43 PDT 2018
Author: svenvh
Date: Fri May 11 02:45:42 2018
New Revision: 332087
URL: http://llvm.org/viewvc/llvm-project?rev=332087&view=rev
Log:
[APFloat] Set losesInfo on no-op convert
losesInfo would be left unset when no conversion needs to be done. A
caller such as InstCombine's fitsInFPType would then branch on an
uninitialized value.
Caught using valgrind on an out-of-tree target.
Differential Revision: https://reviews.llvm.org/D46645
Modified:
llvm/trunk/lib/Support/APFloat.cpp
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=332087&r1=332086&r2=332087&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Fri May 11 02:45:42 2018
@@ -4443,8 +4443,10 @@ APFloat::APFloat(const fltSemantics &Sem
APFloat::opStatus APFloat::convert(const fltSemantics &ToSemantics,
roundingMode RM, bool *losesInfo) {
- if (&getSemantics() == &ToSemantics)
+ if (&getSemantics() == &ToSemantics) {
+ *losesInfo = false;
return opOK;
+ }
if (usesLayout<IEEEFloat>(getSemantics()) &&
usesLayout<IEEEFloat>(ToSemantics))
return U.IEEE.convert(ToSemantics, RM, losesInfo);
More information about the llvm-commits
mailing list