[llvm-branch-commits] [llvm-branch] r352233 - Merging r352204:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 25 11:31:18 PST 2019


Author: hans
Date: Fri Jan 25 11:31:17 2019
New Revision: 352233

URL: http://llvm.org/viewvc/llvm-project?rev=352233&view=rev
Log:
Merging r352204:
------------------------------------------------------------------------
r352204 | sammccall | 2019-01-25 16:05:33 +0100 (Fri, 25 Jan 2019) | 7 lines

[JSON] Work around excess-precision issue when comparing T_Integer numbers.

Reviewers: bkramer

Subscribers: kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D57237
------------------------------------------------------------------------

Modified:
    llvm/branches/release_80/   (props changed)
    llvm/branches/release_80/include/llvm/Support/JSON.h
    llvm/branches/release_80/lib/Support/JSON.cpp

Propchange: llvm/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 25 11:31:17 2019
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,351325,351344-351345,351349,351351,351370,351381,351421,351426,351436,351475,351485,351753-351754,351930,351932,352034
+/llvm/trunk:155241,351325,351344-351345,351349,351351,351370,351381,351421,351426,351436,351475,351485,351753-351754,351930,351932,352034,352204

Modified: llvm/branches/release_80/include/llvm/Support/JSON.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/include/llvm/Support/JSON.h?rev=352233&r1=352232&r2=352233&view=diff
==============================================================================
--- llvm/branches/release_80/include/llvm/Support/JSON.h (original)
+++ llvm/branches/release_80/include/llvm/Support/JSON.h Fri Jan 25 11:31:17 2019
@@ -481,6 +481,7 @@ private:
   mutable llvm::AlignedCharArrayUnion<bool, double, int64_t, llvm::StringRef,
                                       std::string, json::Array, json::Object>
       Union;
+  friend bool operator==(const Value &, const Value &);
 };
 
 bool operator==(const Value &, const Value &);

Modified: llvm/branches/release_80/lib/Support/JSON.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/Support/JSON.cpp?rev=352233&r1=352232&r2=352233&view=diff
==============================================================================
--- llvm/branches/release_80/lib/Support/JSON.cpp (original)
+++ llvm/branches/release_80/lib/Support/JSON.cpp Fri Jan 25 11:31:17 2019
@@ -182,6 +182,12 @@ bool operator==(const Value &L, const Va
   case Value::Boolean:
     return *L.getAsBoolean() == *R.getAsBoolean();
   case Value::Number:
+    // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
+    // The same integer must convert to the same double, per the standard.
+    // However we see 64-vs-80-bit precision comparisons with gcc-7 -O3 -m32.
+    // So we avoid floating point promotion for exact comparisons.
+    if (L.Type == Value::T_Integer || R.Type == Value::T_Integer)
+      return L.getAsInteger() == R.getAsInteger();
     return *L.getAsNumber() == *R.getAsNumber();
   case Value::String:
     return *L.getAsString() == *R.getAsString();




More information about the llvm-branch-commits mailing list