https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115815
--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:005ce1c1826777f33d5011723827d17f1fcd55c1 commit r13-9143-g005ce1c1826777f33d5011723827d17f1fcd55c1 Author: Martin Jambor <mjam...@suse.cz> Date: Fri Oct 18 21:32:16 2024 +0200 ipa: Treat static constructors and destructors as non-local (PR 115815) In PR 115815, IPA-SRA thought it had control over all invocations of a (recursive) static destructor but it did not see the implied invocation which led to the original being left behind and the clean-up code encountering uses of SSAs that definitely should have been dead. Fixed by teaching cgraph_node::can_be_local_p about static constructors and destructors. Similar test is missing in cgraph_node::local_p so I added the check there as well. In addition to the commit with the fix, this backport also contains squashed commit 1a458bdeb223ffa501bac8e76182115681967094 which fixes dejagnu directives in the testcase. gcc/ChangeLog: 2024-07-25 Martin Jambor <mjam...@suse.cz> PR ipa/115815 * cgraph.cc (cgraph_node_cannot_be_local_p_1): Also check DECL_STATIC_CONSTRUCTOR and DECL_STATIC_DESTRUCTOR. * ipa-visibility.cc (non_local_p): Likewise. (cgraph_node::local_p): Delete extraneous line of tabs. gcc/testsuite/ChangeLog: 2024-07-25 Martin Jambor <mjam...@suse.cz> PR ipa/115815 * gcc.dg/lto/pr115815_0.c: New test. (cherry picked from commit e98ad6a049c96c21cf641954584c2f5b7df0ce93)