https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104407

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:be9cd0ca8a5f13cfee6a39b217d439a25c53553a

commit r12-7129-gbe9cd0ca8a5f13cfee6a39b217d439a25c53553a
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Feb 9 15:17:52 2022 +0100

    dwarf2out: Don't call expand_expr during early_dwarf [PR104407]

    As mentioned in the PR, since PR96690 r11-2834 we call rtl_for_decl_init
    which can call expand_expr already during early_dwarf.  The comment and PR
    explains it that the intent is to ensure the referenced vars and functions
    are properly mangled because free_lang_data doesn't cover everything, like
    template parameters etc.  It doesn't work well though, because expand_expr
    can set DECL_RTLs e.g. on referenced vars and keep them there, and they can
    be created e.g. with different MEM_ALIGN compared to what they would be
    created with if they were emitted later.
    So, the following patch stops calling rtl_for_decl_init and instead
    for cases for which rtl_for_decl_init does anything at all walks the
    initializer and ensures referenced vars or functions are mangled.

    2022-02-09  Jakub Jelinek  <ja...@redhat.com>

            PR debug/104407
            * dwarf2out.cc (mangle_referenced_decls): New function.
            (tree_add_const_value_attribute): Don't call rtl_for_decl_init if
            early_dwarf.  Instead walk the initializer and try to mangle vars
or
            functions referenced from it.

            * g++.dg/debug/dwarf2/pr104407.C: New test.

Reply via email to