force read for doNotOptimizeAway(*ptr_to_small_trivial)
authorNathan Bronson <ngbronson@fb.com>
Fri, 18 Nov 2016 16:07:09 +0000 (08:07 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Fri, 18 Nov 2016 16:08:26 +0000 (08:08 -0800)
commitaebb140d3e6d1837294bef12a3d922e40a1a8f08
tree3f3d0a61bb8af311ae8fbf858fd5468dbf437f07
parent005736d3bc1d21fb0415fd68b6233890edc0b31b
force read for doNotOptimizeAway(*ptr_to_small_trivial)

Summary:
doNotOptimizeAway's "X" input operand constraint is interpreted
more loosely by gcc than by clang, resulting in surprising behavior
for doNotOptimizeAway(*ptr) and a difference in behavior between gcc
and clang benchmarks.  clang also is more aggressive about placing an
input operand into a register even when the constraint would allow it to
be in memory, so an "r,m" constraint has a similar problem.  This diff
changes the input constraint so that register-sized values must actually
be copied into a register, which makes the behavior more intuitive and
more consistent across platforms.

Reviewed By: davidtgoldblatt

Differential Revision: D4199767

fbshipit-source-id: aa56a7b11cb3229b95da87295f0dfc38476959d2
folly/Benchmark.h