Commit 9d9dad16 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

work around compiler bug on some platforms

Summary: g++ aggressively inlines F14VectorMap::operator[] calls from some testing loops with the loop index as a key. On platforms that have SSE2 but not SSE4.2 we use a multiplication and xor based bit mixer, which undergoes a strength reduction in optimized builds. Somehow the resulting code miscalculates the result (no minimal repro yet), which causes the tests to persistently fail. This diff blocks the compiler optimization, allowing the tests to pass.

Reviewed By: yfeldblum

Differential Revision: D19910180

fbshipit-source-id: 6cccba67645481061f923bd7b3e681df573c4039
parent 4534b679
......@@ -21,6 +21,7 @@
#include <glog/logging.h>
#include <folly/Benchmark.h>
#include <folly/Conv.h>
#include <folly/FBString.h>
#include <folly/container/test/F14TestUtil.h>
......@@ -138,6 +139,7 @@ void runVisitContiguousRangesTest(int n) {
M map;
for (int i = 0; i < n; ++i) {
folly::makeUnpredictable(i);
map[i] = i;
map.erase(i / 2);
}
......@@ -1964,12 +1966,14 @@ void runContinuousCapacityTest(std::size_t minSize, std::size_t maxSize) {
m2 = m1;
EXPECT_LE(m2.bucket_count(), 2);
for (K i = 1; i < n; ++i) {
folly::makeUnpredictable(i);
m1[i];
}
EXPECT_EQ(m1.bucket_count(), cap);
M m3 = m1;
EXPECT_EQ(m3.bucket_count(), cap);
for (K i = n; i <= cap; ++i) {
folly::makeUnpredictable(i);
m1[i];
}
EXPECT_GT(m1.bucket_count(), cap);
......@@ -1977,6 +1981,7 @@ void runContinuousCapacityTest(std::size_t minSize, std::size_t maxSize) {
M m4;
for (K i = 0; i < n; ++i) {
folly::makeUnpredictable(i);
m4[i];
}
// reserve(0) works like shrink_to_fit. Note that tight fit (1/8
......
......@@ -26,6 +26,7 @@ FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
#include <glog/logging.h>
#include <folly/Benchmark.h>
#include <folly/Conv.h>
#include <folly/FBString.h>
#include <folly/container/test/F14TestUtil.h>
......@@ -141,6 +142,7 @@ void runVisitContiguousRangesTest(int n) {
S set;
for (int i = 0; i < n; ++i) {
folly::makeUnpredictable(i);
set.insert(i);
set.erase(i / 2);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment