summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-03-22 21:28:09 +0000
committerEric Fiselier <eric@efcs.ca>2018-03-22 21:28:09 +0000
commit107d6d684539a034c6ab3a1ae915179c5bbde8ba (patch)
tree1f7689bd71145d5448f9917ba8ca589ec742efde /libcxx/test/support
parent29a21bab087dbb2c8c7e815f4816c4d5356361f9 (diff)
downloadbcm5719-llvm-107d6d684539a034c6ab3a1ae915179c5bbde8ba.tar.gz
bcm5719-llvm-107d6d684539a034c6ab3a1ae915179c5bbde8ba.zip
Use DoNotOptimize to prevent new/delete elision.
The new/delete tests, in particular those which test replacement functions, often fail when the optimizer is enabled because the calls to new/delete may be optimized away, regardless of their side-effects. This patch converts the tests to use DoNotOptimize in order to prevent the elision. llvm-svn: 328245
Diffstat (limited to 'libcxx/test/support')
-rw-r--r--libcxx/test/support/test_macros.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 42eed4ce498..848f1407635 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -221,8 +221,18 @@ struct is_same<T, T> { enum {value = 1}; };
#if defined(__GNUC__) || defined(__clang__)
template <class Tp>
-inline void DoNotOptimize(Tp const& value) {
- asm volatile("" : : "g"(value) : "memory");
+inline
+void DoNotOptimize(Tp const& value) {
+ asm volatile("" : : "r,m"(value) : "memory");
+}
+
+template <class Tp>
+inline void DoNotOptimize(Tp& value) {
+#if defined(__clang__)
+ asm volatile("" : "+r,m"(value) : : "memory");
+#else
+ asm volatile("" : "+m,r"(value) : : "memory");
+#endif
}
#else
#include <intrin.h>
OpenPOWER on IntegriCloud