Revert^3 "Use DoNotOptimize rather than rely on a volatile."
This reverts commit aad7abbd31a93a43da3163331d5ceb02d7c09fcb.
Reason for revert: DroidMonitor: Potential culprit for http://b/370545152 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted
Change-Id: Id35ba5d9c986d83357d4acff9dc17ce67049439a
diff --git a/tests/utils.h b/tests/utils.h
index 4740e59..3c83b73 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -295,6 +295,16 @@
size_t start_count_ = CountOpenFds();
};
+// From <benchmark/benchmark.h>.
+template <class Tp>
+static inline void DoNotOptimize(Tp const& value) {
+ asm volatile("" : : "r,m"(value) : "memory");
+}
+template <class Tp>
+static inline void DoNotOptimize(Tp& value) {
+ asm volatile("" : "+r,m"(value) : : "memory");
+}
+
static inline bool running_with_mte() {
#ifdef __aarch64__
int level = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);