Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Issue 1019233002: Subzero: Fix floating-point constant pooling. (Closed)

Created:
5 years, 9 months ago by Jim Stichnoth
Modified:
5 years, 9 months ago
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Fix floating-point constant pooling. This fixes a regression likely introduced in d2cb4361c732dcddc98659415f37be45982e20c3 . The problem is that by using the default std::unordered_map comparison predicate std::equal_to, we get incorrect behavior when the key is float or double: 1. 0.0 and -0.0 appear equal, so they share a constant pool entry even though the bit patterns are different. This is a correctness bug. 2. Each instance of NaN gets a separate constant pool entry, because NaN != NaN by C equality rules. This is a performance bug. (This problem doesn't show up with the native bitcode reader, because constants are already unique-ified in the PNaCl bitcode file.) The solution is to use memcmp for floating-point key types. Also, the abi-atomics.ll test is disabled for the MINIMAL build, to fix an oversight from a previous CL. BUG= none R=jfb@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=5bfe21578536c437ef17052038c5d85eaf1bd484

Patch Set 1 #

Total comments: 7

Patch Set 2 : Improve key comparison for unordered_map #

Patch Set 3 : Simplification #

Total comments: 2

Patch Set 4 : Add a comment on use of default std::hash #

Unified diffs Side-by-side diffs Delta from patch set Stats (+108 lines, -1 line) Patch
M src/IceGlobalContext.cpp View 1 2 3 3 chunks +35 lines, -1 line 0 comments Download
M tests_lit/llvm2ice_tests/abi-atomics.ll View 1 chunk +2 lines, -0 lines 0 comments Download
A tests_lit/llvm2ice_tests/fp_const_pool.ll View 1 1 chunk +71 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (1 generated)
Jim Stichnoth
This and the fabs implementation allow Subzero to pass the LLVM test suite.
5 years, 9 months ago (2015-03-19 08:46:11 UTC) #2
JF
https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp#newcode76 src/IceGlobalContext.cpp:76: ContainerType; template<typename T> struct Compare { typename std::enable_if<std::is_integral<T>::value, bool>::type ...
5 years, 9 months ago (2015-03-19 16:33:09 UTC) #3
Jim Stichnoth
https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp#newcode76 src/IceGlobalContext.cpp:76: ContainerType; On 2015/03/19 16:33:09, JF wrote: > template<typename T> ...
5 years, 9 months ago (2015-03-19 18:07:05 UTC) #4
Jim Stichnoth
https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/1019233002/diff/1/src/IceGlobalContext.cpp#newcode76 src/IceGlobalContext.cpp:76: ContainerType; On 2015/03/19 18:07:04, stichnot wrote: > On 2015/03/19 ...
5 years, 9 months ago (2015-03-19 19:57:49 UTC) #5
JF
lgtm https://codereview.chromium.org/1019233002/diff/40001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/1019233002/diff/40001/src/IceGlobalContext.cpp#newcode93 src/IceGlobalContext.cpp:93: KeyCompare<KeyType>> ContainerType; Comment on why using std::hash is ...
5 years, 9 months ago (2015-03-19 20:33:12 UTC) #6
Jim Stichnoth
Committed patchset #4 (id:60001) manually as 5bfe21578536c437ef17052038c5d85eaf1bd484 (presubmit successful).
5 years, 9 months ago (2015-03-19 20:52:06 UTC) #7
Jim Stichnoth
5 years, 9 months ago (2015-03-20 05:29:49 UTC) #8
Message was sent while issue was closed.
https://codereview.chromium.org/1019233002/diff/40001/src/IceGlobalContext.cpp
File src/IceGlobalContext.cpp (right):

https://codereview.chromium.org/1019233002/diff/40001/src/IceGlobalContext.cp...
src/IceGlobalContext.cpp:93: KeyCompare<KeyType>> ContainerType;
On 2015/03/19 20:33:12, JF wrote:
> Comment on why using std::hash is OK here but the default comparator wasn't.

Done.

Powered by Google App Engine
This is Rietveld 408576698