]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add cold attribute to throw wrappers and terminate
authorJan Hubicka <jh@suse.cz>
Wed, 28 Jun 2023 09:45:15 +0000 (11:45 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 28 Jun 2023 09:47:11 +0000 (11:47 +0200)
PR middle-end/109849
* include/bits/c++config (std::__terminate): Mark cold.
* include/bits/functexcept.h: Mark everything as cold.
* libsupc++/exception: Mark terminate and unexpected as cold.

libstdc++-v3/include/bits/c++config
libstdc++-v3/include/bits/functexcept.h
libstdc++-v3/libsupc++/exception

index 009a017b048f2e5e8fa46a713c9f7f5404d1e4a2..dd47f274d5ff4d4915173961c3b4f1968cf00a07 100644 (file)
@@ -320,7 +320,7 @@ namespace std
   extern "C++" __attribute__ ((__noreturn__, __always_inline__))
   inline void __terminate() _GLIBCXX_USE_NOEXCEPT
   {
-    void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__));
+    void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__,__cold__));
     terminate();
   }
 #pragma GCC visibility pop
index 89972baf2c9b799c6d641e444826581a7ff02504..c43ca82b9530e8d9e45f88b53951981b3f2c6df7 100644 (file)
@@ -57,61 +57,61 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Helper for exception objects in <typeinfo>
   void
-  __throw_bad_cast(void) __attribute__((__noreturn__));
+  __throw_bad_cast(void) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_bad_typeid(void) __attribute__((__noreturn__));
+  __throw_bad_typeid(void) __attribute__((__noreturn__,__cold__));
 
   // Helpers for exception objects in <stdexcept>
   void
-  __throw_logic_error(const char*) __attribute__((__noreturn__));
+  __throw_logic_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_domain_error(const char*) __attribute__((__noreturn__));
+  __throw_domain_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_invalid_argument(const char*) __attribute__((__noreturn__));
+  __throw_invalid_argument(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_length_error(const char*) __attribute__((__noreturn__));
+  __throw_length_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_out_of_range(const char*) __attribute__((__noreturn__));
+  __throw_out_of_range(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__))
+  __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__,__cold__))
     __attribute__((__format__(__gnu_printf__, 1, 2)));
 
   void
-  __throw_runtime_error(const char*) __attribute__((__noreturn__));
+  __throw_runtime_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_range_error(const char*) __attribute__((__noreturn__));
+  __throw_range_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_overflow_error(const char*) __attribute__((__noreturn__));
+  __throw_overflow_error(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_underflow_error(const char*) __attribute__((__noreturn__));
+  __throw_underflow_error(const char*) __attribute__((__noreturn__,__cold__));
 
   // Helpers for exception objects in <ios>
   void
-  __throw_ios_failure(const char*) __attribute__((__noreturn__));
+  __throw_ios_failure(const char*) __attribute__((__noreturn__,__cold__));
 
   void
-  __throw_ios_failure(const char*, int) __attribute__((__noreturn__));
+  __throw_ios_failure(const char*, int) __attribute__((__noreturn__,__cold__));
 
   // Helpers for exception objects in <system_error>
   void
-  __throw_system_error(int) __attribute__((__noreturn__));
+  __throw_system_error(int) __attribute__((__noreturn__,__cold__));
 
   // Helpers for exception objects in <future>
   void
-  __throw_future_error(int) __attribute__((__noreturn__));
+  __throw_future_error(int) __attribute__((__noreturn__,__cold__));
 
   // Helpers for exception objects in <functional>
   void
-  __throw_bad_function_call() __attribute__((__noreturn__));
+  __throw_bad_function_call() __attribute__((__noreturn__,__cold__));
 
 #else // ! HOSTED
 
index a34386e6026a5749fcd0d0acdddc987ab49f2def..00a6347ebe529b9bf984a0d18ef4a8faada18417 100644 (file)
@@ -75,7 +75,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
   /** The runtime will call this function if %exception handling must be
    *  abandoned for any reason.  It can also be called by the user.  */
-  void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__));
+  void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__,__cold__));
 
 #if __cplusplus < 201703L || (__cplusplus <= 202002L && _GLIBCXX_USE_DEPRECATED)
   /// If you write a replacement %unexpected handler, it must be of this type.
@@ -104,7 +104,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
    * @deprecated Removed from the C++ standard in C++17
    */
   _GLIBCXX11_DEPRECATED
-  void unexpected() __attribute__ ((__noreturn__));
+  void unexpected() __attribute__ ((__noreturn__,__cold__));
 #endif
 
   /** [18.6.4]/1:  'Returns true after completing evaluation of a