aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/method.cc
diff options
context:
space:
mode:
authorJavier Martinez <javier.martinez.bugzilla@gmail.com>2023-08-23 15:02:40 +0200
committerJason Merrill <jason@redhat.com>2023-09-19 15:03:28 -0400
commit4f52e61e0665e760b95975b4d49437873967be2e (patch)
treed295e1e617ed5c9275f70a637703c30511c06aa9 /gcc/cp/method.cc
parentb9912332c5b6fc9433ee11f5488acad117868888 (diff)
downloadgcc-4f52e61e0665e760b95975b4d49437873967be2e.zip
gcc-4f52e61e0665e760b95975b4d49437873967be2e.tar.gz
gcc-4f52e61e0665e760b95975b4d49437873967be2e.tar.bz2
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>
Diffstat (limited to 'gcc/cp/method.cc')
-rw-r--r--gcc/cp/method.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index 4ba0017..a70dd5d 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -3592,6 +3592,12 @@ lazily_declare_fn (special_function_kind sfk, tree type)
/* Create appropriate clones. */
clone_cdtor (fn, /*update_methods=*/true);
+ /* Classes, structs or unions TYPE marked with hotness attributes propagate
+ the attribute to all methods. This is typically done in
+ check_bases_and_members, but we must also inject them here for deferred
+ lazily-declared functions. */
+ maybe_propagate_warmth_attributes (fn, type);
+
return fn;
}