[PATCH] Add cold attribute to one time construction APIs
Aditya K
hiraditya@msn.com
Mon Aug 17 18:15:15 GMT 2020
This would help compiler optimize local static objects.
Added changelog.
```
>From c6cba40e0434147db89d3af05b598782cde651e3 Mon Sep 17 00:00:00 2001
From: Aditya Kumar <1894981+hiraditya@users.noreply.github.com>
Date: Thu, 13 Aug 2020 09:41:34 -0700
Subject: [PATCH] Add cold attribute to one time construction APIs
__cxa_guard_acquire is used for only one purpose,
namely guarding local static variable initialization,
and since that purpose is definitionally cold, it should be attributed as cold.
Similarly for __cxa_guard_release and __cxa_guard_abort
---
libstdc++-v3/ChangeLog | 5 +++++
libstdc++-v3/include/bits/c++config | 5 +++++
libstdc++-v3/libsupc++/cxxabi.h | 6 +++---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fe6884bf3..86b707ac7 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2020-08-17 Aditya Kumar <hiraditya@msn.com>
+ * libstdc++-v3/include/bits/c++config: Add _GLIBCXX_NOTHROW attribute
+ * libstdc++-v3/libsupc++/cxxabi.h (__cxa_guard_acquire, __cxa_guard_release,
+ __cxa_guard_abort): Add _GLIBCXX_NOTHROW attribute.
+
2020-08-14 Lewis Hyatt <lhyatt@gmail.com>
* testsuite/lib/libstdc++.exp: Use the new option
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index b1fad59d4..f6f954eef 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -42,6 +42,7 @@
// _GLIBCXX_NORETURN
// _GLIBCXX_NOTHROW
// _GLIBCXX_VISIBILITY
+// _GLIBCXX_COLD
#ifndef _GLIBCXX_PURE
# define _GLIBCXX_PURE __attribute__ ((__pure__))
#endif
@@ -74,6 +75,10 @@
# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
+#ifndef _GLIBCXX_COLD
+# define _GLIBCXX_COLD __attribute__ ((cold))
+#endif
+
// Macros for deprecated attributes.
// _GLIBCXX_USE_DEPRECATED
// _GLIBCXX_DEPRECATED
diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
index 000713ecd..24c1366e2 100644
--- a/libstdc++-v3/libsupc++/cxxabi.h
+++ b/libstdc++-v3/libsupc++/cxxabi.h
@@ -115,13 +115,13 @@ namespace __cxxabiv1
void (*__dealloc) (void*, size_t));
int
- __cxa_guard_acquire(__guard*);
+ __cxa_guard_acquire(__guard*) _GLIBCXX_COLD;
void
- __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
+ __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
void
- __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
+ __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
// DSO destruction.
int
--
2.13.5
```
More information about the Libstdc++
mailing list