https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118125
--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:4abac2ffdb071ca9337e4f31fa79cd38df1ac7c3 commit r15-7476-g4abac2ffdb071ca9337e4f31fa79cd38df1ac7c3 Author: Martin Jambor <mjam...@suse.cz> Date: Tue Feb 11 16:39:56 2025 +0100 lto: Add an entry for cold attribute to lto_gnu_attributes PR 118125 is a performance regression stemming from the fact that we lose the cold attribute of our __builtin_unreachable. The attribute is simply and silently dropped on the floor by decl_attributes (in attribs.cc) in the process of building decls for builtins because it cannot look it up in the gnu attribute name space by lookup_scoped_attribute_spec. For that not to happen it must be in lto_gnu_attributes and this patch adds it there. In comment 13 of the bug Andrew identified other attributes which are in builtin-attrs.def but missing in lto_gnu_attributes but apart from cold it seems that they are either not used in builtins.def or are used in DEF_LIB_BUILTIN which I guess might be less critical? Eventually I decided to go for the most simple of patches and only add things if they are requested. For the same reason I also did not add any checking to the attribute "handle" callback or any exclusion check. They seem to be mostly relevant before LTO FE kicks in to me, but again, I'm happy to add any if they seem to be useful. Since Ian fixed PR 118746, the same issue has also been fixed in the Go front-end and so I have added a simple checking assert to the redirect_to_unreachable function to make sure it has the intended effect. gcc/ChangeLog: 2025-02-03 Martin Jambor <mjam...@suse.cz> PR lto/118125 * ipa-fnsummary.cc (redirect_to_unreachable): Add checking assert that the builtin_unreachable decl has attribute cold. gcc/lto/ChangeLog: 2025-02-03 Martin Jambor <mjam...@suse.cz> PR lto/118125 * lto-lang.cc (lto_gnu_attributes): Add an entry for cold attribute. (handle_cold_attribute): New function.