Skip to content

Commit 3f94851

Browse files
committed
[libcxx] Update DoNotOptimize variant to accept L and R value variables.
As part of the libcxx tests, there is a function provided called `DoNotOptimize`. The tests currently utilise a version which only uses the value as an input, leading to the compiler not removing information relating to the data-flow for the value. This leads to issues when comparing the pointer values, where one is a global pointer and the other a pointer which is local to the function being executed. Another version of `DoNotOptimize` is available which allows for the value to be an input and output of the inline assembly, which allows for the pointers to be successfully compared to one another. This function however only accepts an L Value reference, where the values are initialized as R value reference, so use the variant of `DoNotOptmize` described in the first paragraph. To enable the use of the second variant in the tests, the type of reference has been updated so it allows both R and L value references as the input value. This enables the use of the correct version of the function for the tests.
1 parent 20d653f commit 3f94851

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libcxx/test/support/test_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
296296
}
297297

298298
template <class Tp>
299-
inline Tp& DoNotOptimize(Tp& value) {
299+
inline Tp& DoNotOptimize(Tp&& value) {
300300
#if defined(__clang__)
301301
asm volatile("" : "+r,m"(value) : : "memory");
302302
#else

0 commit comments

Comments
 (0)