[libcxx] r297532 - Fix DoNotOptimize on MSVC
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 10 16:07:08 PST 2017
Author: ericwf
Date: Fri Mar 10 18:07:08 2017
New Revision: 297532
URL: http://llvm.org/viewvc/llvm-project?rev=297532&view=rev
Log:
Fix DoNotOptimize on MSVC
Modified:
libcxx/trunk/test/support/test_macros.h
Modified: libcxx/trunk/test/support/test_macros.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=297532&r1=297531&r2=297532&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Fri Mar 10 18:07:08 2017
@@ -188,9 +188,11 @@ inline void DoNotOptimize(Tp const& valu
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
More information about the cfe-commits
mailing list