Fix DoNotOptimize on MSVC

llvm-svn: 297532
This commit is contained in:
Eric Fiselier 2017-03-11 00:07:08 +00:00
parent c28c7e5bd3
commit d2001dac3f
1 changed files with 4 additions and 2 deletions

View File

@ -188,9 +188,11 @@ inline void DoNotOptimize(Tp const& value) {
asm volatile("" : : "g"(value) : "memory");
}
#else
#include <intrin.h>
template <class Tp>
inline void DoNotOptimize(Tp const&) {
// FIXME: Do something here...
inline void DoNotOptimize(Tp const& value) {
const volatile void* volatile = __builtin_addressof(value);
_ReadWriteBarrier();
}
#endif