aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-12-01 20:58:58 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-12-02 16:46:28 +0000
commitb5a568683f71b4a8b1e4e45a43484398e9a66ff2 (patch)
tree3fcc70af8566481446db259a09d3c451d49b704e
parentd08236359eb22918ba067489edcec02857109d09 (diff)
downloadgcc-b5a568683f71b4a8b1e4e45a43484398e9a66ff2.zip
gcc-b5a568683f71b4a8b1e4e45a43484398e9a66ff2.tar.gz
gcc-b5a568683f71b4a8b1e4e45a43484398e9a66ff2.tar.bz2
libstdc++: Restore unconditional atomic load in COW std::string
The relaxed load is already optimal, checking the __single_threaded global before doing a non-atomic load isn't an optimization. libstdc++-v3/ChangeLog: * include/bits/cow_string.h (basic_string::_M_is_leaked()): Revert change to check __is_single_threaded() before using atomic load.
-rw-r--r--libstdc++-v3/include/bits/cow_string.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index d6ddf34..389b395 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -207,10 +207,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// so we need to use an atomic load. However, _M_is_leaked
// predicate does not change concurrently (i.e. the string is either
// leaked or not), so a relaxed load is enough.
- if (!__gnu_cxx::__is_single_threaded())
- return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
-#endif
+ return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
+#else
return this->_M_refcount < 0;
+#endif
}
bool