[PATCH] D46645: [APFloat] Set losesInfo on no-op convert

Sven van Haastregt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 9 09:27:55 PDT 2018


svenvh created this revision.
svenvh added a reviewer: timshen.
Herald added a subscriber: llvm-commits.

`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.


Repository:
  rL LLVM

https://reviews.llvm.org/D46645

Files:
  lib/Support/APFloat.cpp


Index: lib/Support/APFloat.cpp
===================================================================
--- lib/Support/APFloat.cpp
+++ lib/Support/APFloat.cpp
@@ -4441,8 +4441,10 @@
 
 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46645.145937.patch
Type: text/x-patch
Size: 598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180509/580bdc73/attachment.bin>


More information about the llvm-commits mailing list