]> git.ipfire.org Git - thirdparty/gcc.git/commit
dwarf2out: Don't call expand_expr during early_dwarf [PR104407]
authorJakub Jelinek <jakub@redhat.com>
Wed, 9 Feb 2022 14:17:52 +0000 (15:17 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 9 Feb 2022 14:17:52 +0000 (15:17 +0100)
commitbe9cd0ca8a5f13cfee6a39b217d439a25c53553a
treedf128b7a16483ac0fad48cf82c9ffde9dbaa93c0
parentc6bb1db76b3ac127aff7dacf391fc1798a94bb7d
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  <jakub@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.
gcc/dwarf2out.cc
gcc/testsuite/g++.dg/debug/dwarf2/pr104407.C [new file with mode: 0644]