public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-3339] libstdc++: Use __builtin_expect in __glibcxx_assert
@ 2020-09-21 22:43 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-09-21 22:43 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:7db5967f1050eb2b45e920b13d495d92ba4f16f4

commit r11-3339-g7db5967f1050eb2b45e920b13d495d92ba4f16f4
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Sep 21 23:43:25 2020 +0100

    libstdc++: Use __builtin_expect in __glibcxx_assert
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/c++config (__replacement_assert): Add noreturn
            attribute.
            (__glibcxx_assert_impl): Use __builtin_expect to hint that the
            assertion is expected to pass.

Diff:
---
 libstdc++-v3/include/bits/c++config | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index badf9d01a04..860bf6dbcb3 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -468,7 +468,8 @@ namespace std
 {
   // Avoid the use of assert, because we're trying to keep the <cassert>
   // include out of the mix.
-  extern "C++" inline void
+  extern "C++" _GLIBCXX_NORETURN
+  inline void
   __replacement_assert(const char* __file, int __line,
 		       const char* __function, const char* __condition)
   {
@@ -478,7 +479,7 @@ namespace std
   }
 }
 #define __glibcxx_assert_impl(_Condition)			       \
-  if (!bool(_Condition))					       \
+  if (__builtin_expect(!bool(_Condition), false))		       \
     std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
 			      #_Condition)
 #endif


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-21 22:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 22:43 [gcc r11-3339] libstdc++: Use __builtin_expect in __glibcxx_assert Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).