]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add cold attribute to assertion failure functions [PR117650]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 27 Nov 2024 11:52:40 +0000 (11:52 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 27 Nov 2024 21:36:14 +0000 (21:36 +0000)
This helps the compiler to split the cold path into a separate clone, so
that the hot path is a smaller function that uses less icache, and the
cold path is only fetched into the icache if actually executed.

libstdc++-v3/ChangeLog:

PR libstdc++/117650
* include/bits/c++config (__glibcxx_assert_fail): Add cold
attribute.
* include/debug/formatter.h (_Error_formatter::_M_error):
Likewise.

libstdc++-v3/include/bits/c++config
libstdc++-v3/include/debug/formatter.h

index 236906d2f79f4409923d688d082ca17083d17273..c74b03013fdb260ef865eaf49e5f83077d433478 100644 (file)
@@ -610,7 +610,7 @@ namespace std
 {
 #pragma GCC visibility push(default)
   // Don't use <cassert> because this should be unaffected by NDEBUG.
-  extern "C++" _GLIBCXX_NORETURN
+  extern "C++" _GLIBCXX_NORETURN __attribute__((__cold__))
   void
   __glibcxx_assert_fail /* Called when a precondition violation is detected. */
     (const char* __file, int __line, const char* __function,
index 4f5a4539bb9ffe16d75e16d2010ed35ac36180f3..df7f6965a4c8f40bfc6bfe21cf63bda828b030ed 100644 (file)
@@ -571,7 +571,7 @@ namespace __gnu_debug
     _Error_formatter&
     _M_message(_Debug_msg_id __id) const throw ();
 
-    _GLIBCXX_NORETURN void
+    _GLIBCXX_NORETURN __attribute__((__cold__)) void
     _M_error() const;
 
 #if !_GLIBCXX_INLINE_VERSION