]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: extend cold, hot attributes to classes
authorJavier Martinez <javier.martinez.bugzilla@gmail.com>
Wed, 23 Aug 2023 13:02:40 +0000 (15:02 +0200)
committerJason Merrill <jason@redhat.com>
Tue, 19 Sep 2023 19:03:28 +0000 (15:03 -0400)
commit4f52e61e0665e760b95975b4d49437873967be2e
treed295e1e617ed5c9275f70a637703c30511c06aa9
parentb9912332c5b6fc9433ee11f5488acad117868888
c++: extend cold, hot attributes to classes

Most code is cold. This patch extends support for attribute ((cold)) to C++
Classes, Unions, and Structs (RECORD_TYPES and UNION_TYPES) to benefit from
encapsulation - reducing the verbosity of using the attribute where
deserved. The ((hot)) attribute is also extended for its semantic relation.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_hot_attribute): remove warning on
RECORD_TYPE and UNION_TYPE when in c_dialect_xx.
(handle_cold_attribute): Likewise.

gcc/cp/ChangeLog:

* class.cc (propagate_class_warmth_attribute): New function.
(check_bases_and_members): propagate hot and cold attributes
to all FUNCTION_DECL when the record is marked hot or cold.
* cp-tree.h (maybe_propagate_warmth_attributes): New function.
* decl2.cc (maybe_propagate_warmth_attributes): New function.
* method.cc (lazily_declare_fn): propagate hot and cold
attributes to lazily declared functions when the record is
marked hot or cold.

gcc/ChangeLog:

* doc/extend.texi: Document attributes hot, cold on C++ types.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-hotness.C: New test.

Signed-off-by: Javier Martinez <javier.martinez.bugzilla@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/c-family/c-attribs.cc
gcc/cp/class.cc
gcc/cp/cp-tree.h
gcc/cp/decl2.cc
gcc/cp/method.cc
gcc/doc/extend.texi
gcc/testsuite/g++.dg/ext/attr-hotness.C [new file with mode: 0644]