aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorbulatman <bulatman@yandex-team.com>2023-06-12 21:00:15 +0300
committerbulatman <bulatman@yandex-team.com>2023-06-12 21:00:15 +0300
commit640dbbe9b05b4b54bef29c5e3cf25d73bdcaf4a7 (patch)
treeef069101a8ca0a2ec5262ec946183922f4773fa6 /util
parent5b8f29b315eddeae7cbfa8f52711aea1d2404581 (diff)
downloadydb-640dbbe9b05b4b54bef29c5e3cf25d73bdcaf4a7.tar.gz
Delete constant reference API to DoNotOptimizeAway
Diffstat (limited to 'util')
-rw-r--r--util/system/compiler.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/system/compiler.h b/util/system/compiler.h
index 953837f919..55448c932e 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -635,6 +635,15 @@ Y_FORCE_INLINE void DoNotOptimizeAway(T&& datum) {
#endif
}
+/**
+ * The usage for `const T&` is prohibited.
+ * The compiler assume that a constant reference, even though escaped via asm volatile, is unchanged.
+ * The const-ref interface is deleted to discourage new uses of it, as subtle compiler optimizations (invariant hoisting, etc.) can occur.
+ * For more details see https://github.com/google/benchmark/pull/1493.
+ */
+template <typename T>
+Y_FORCE_INLINE void DoNotOptimizeAway(const T&) = delete;
+
/**
* Use this macro to prevent unused variables elimination.
*/