On 18/08/20 15:35 +0100, Jonathan Wakely wrote:
On 17/08/20 18:15 +0000, Aditya K via Libstdc++ wrote:
This would help compiler optimize local static objects.
Added changelog.
Please don't :-)
GCC patch policies always said NOT to change the ChangeLog in the
patch, because the ChangeLog files change so rapidly that it means by
the time you've sent the patch, it no longer applies.
Current GCC policies are that NOBODY changes the ChangeLog files, they
are autogenerated from Git commit logs once per day.
So please just include the proposed ChangeLog entry as the Git commit
message in the body of your email.
Patch for libstdc++ need to go to both the libstdc++ list and the
gcc-patches list, in the same email. Not sent once to each list as
separate emails.
```
From c6cba40e0434147db89d3af05b598782cde651e3 Mon Sep 17 00:00:00 2001
From: Aditya Kumar <1894981+hiradi...@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.
Definitionally isn't a word. Attributed is a word, but it doesn't mean
marked with an attribute.
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 <hiradi...@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.
The changelog format is wrong. There should be a blank line after the
date+author line, and you're adding _GLIBCXX_COLD not
_GLIBCXX_NOTHROW. But it shouldn't be here at all as explained above.
2020-08-14 Lewis Hyatt <lhy...@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
"cold" is not a reserved name so this needs to be __cold__.
I've just pushed the attached patch which ensures we don't use the
non-reserved form of the attribute.
Tested x86_64-linux, committed to trunk.
commit 6c1a58b7fbdaa8ac00957fccfb379af163309311
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Tue Aug 18 15:37:14 2020
libstdc++: Add "cold" to tests for reserved attribute names
libstdc++-v3/ChangeLog:
* testsuite/17_intro/headers/c++1998/all_attributes.cc: Check
"cold" isn't used in the library. Also check <cxxabi.h>.
* testsuite/17_intro/headers/c++2011/all_attributes.cc:
Likewise.
* testsuite/17_intro/headers/c++2014/all_attributes.cc:
Likewise.
* testsuite/17_intro/headers/c++2017/all_attributes.cc:
Likewise.
* testsuite/17_intro/headers/c++2020/all_attributes.cc:
Likewise.
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
index 73a20e346e4..dd28429e1d5 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
@@ -21,6 +21,7 @@
// Ensure the library only uses the __name__ form for attributes.
// Don't test 'const' because it is reserved anyway.
#define abi_tag 1
+#define cold 1
#ifndef __APPLE__
// darwin headers use these, see PR 64883
# define always_inline 1
@@ -36,6 +37,7 @@
#endif
#include <bits/extc++.h>
+#include <cxxabi.h>
int
main()
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
index c0a79e06ddc..db00a33f6a3 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
@@ -21,6 +21,7 @@
// Ensure the library only uses the __name__ form for attributes.
// Don't test 'const' and 'noreturn' because they are reserved anyway.
#define abi_tag 1
+#define cold 1
#ifndef __APPLE__
// darwin headers use these, see PR 64883
# define always_inline 1
@@ -35,6 +36,7 @@
#endif
#include <bits/extc++.h>
+#include <cxxabi.h>
int
main()
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
index 1e3ba0888a0..3322c2c1362 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
@@ -21,6 +21,7 @@
// Ensure the library only uses the __name__ form for attributes.
// Don't test 'const' and 'noreturn' because they are reserved anyway.
#define abi_tag 1
+#define cold 1
#ifndef __APPLE__
// darwin headers use these, see PR 64883
# define always_inline 1
@@ -35,6 +36,7 @@
#endif
#include <bits/extc++.h>
+#include <cxxabi.h>
int
main()
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
index 035526e24cb..a0d67739d71 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
@@ -21,6 +21,7 @@
// Ensure the library only uses the __name__ form for attributes.
// Don't test 'const' and 'noreturn' because they are reserved anyway.
#define abi_tag 1
+#define cold 1
#ifndef __APPLE__
// darwin headers use these, see PR 64883
# define always_inline 1
@@ -34,6 +35,7 @@
#endif
#include <bits/extc++.h>
+#include <cxxabi.h>
int
main()
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
index 6f5ea460fac..da8f0e415a3 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
@@ -21,6 +21,7 @@
// Ensure the library only uses the __name__ form for attributes.
// Don't test 'const' and 'noreturn' because they are reserved anyway.
#define abi_tag 1
+#define cold 1
#ifndef __APPLE__
// darwin headers use these, see PR 64883
# define always_inline 1
@@ -34,6 +35,7 @@
#endif
#include <bits/extc++.h>
+#include <cxxabi.h>
int
main()