improvements to folly::doNotOptimizeAway
Summary: A common failure mode for folly::doNotOptimizeAway is to pass it a pointer to a complex object that the caller wants to ensure is fully calculated, which doesn't actually ensure that. Also, the GCC and MSVC implementations used inline assembly with an in-out parameter, which causes a store. A survey of many usages of doNotOptimizeAway found only 1 that relies on this make-unpredictable behavior. This diff makes doNotOptimizeAway(&x) equivalent to doNotOptimizeAway(x) for GCC and clang, and makes it a read-only sink. For the rare case that the benchmark wants to disable subexpression elimination, constant propagation, or power reduction, there is a new function makeUnpredictable. It also merges the clang and GCC implementations, removing a potential bias in our microbenchmarks. Reviewed By: davidtgoldblatt Differential Revision: D4074670 fbshipit-source-id: 43f02e7fe149147bb172babe77787dea06e098fa
Showing
Please register or sign in to comment