diff options
author | Richard Biener <rguenther@suse.de> | 2023-03-01 10:01:10 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-03-03 08:26:58 +0100 |
commit | 33ca5c92dfa7e2f591a838bb768d9d6eea56793b (patch) | |
tree | 2bba54a8e803c6d866524e0db0d9a3904c610ef9 /gcc/dwarf2out.cc | |
parent | 1e4122f1159ace52c114c011013adce25172d77b (diff) | |
download | gcc-33ca5c92dfa7e2f591a838bb768d9d6eea56793b.zip gcc-33ca5c92dfa7e2f591a838bb768d9d6eea56793b.tar.gz gcc-33ca5c92dfa7e2f591a838bb768d9d6eea56793b.tar.bz2 |
debug/108772 - ICE with late debug generated with -flto
When combining -g1 with -flto we run into the DIE location annotation
machinery for globals calling dwarf2out_late_global_decl but not
having any early generated DIE for function scope statics. In
this process we'd generate a limbo DIE since also the function scope
doesn't have any early generated DIE. The limbo handling then tries
to force a DIE for the context chain which ultimatively fails and
ICEs at the std namespace decl because at -g1 we don't represent that.
The following avoids this situation by making sure to never generate
any DIEs from dwarf2out_late_global_decl in the in_lto_p path
for function scope globals but rely on DIE generation for
the function to output a DIE for the local static (which doesn't
happen for -g1).
I explored a lot of other options to fix this but in the end this
seems to be the most spot-on fix with the least risk of unwanted
effects.
PR debug/108772
* dwarf2out.cc (dwarf2out_late_global_decl): Do not
generate a DIE for a function scope static.
* g++.dg/lto/pr108772_0.C: New testcase.
Diffstat (limited to 'gcc/dwarf2out.cc')
-rw-r--r-- | gcc/dwarf2out.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 1f39df3..1711ad2 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -27282,7 +27282,10 @@ dwarf2out_late_global_decl (tree decl) /* We may have to generate full debug late for LTO in case debug was not enabled at compile-time or the target doesn't support the LTO early debug scheme. */ - if (! die && in_lto_p) + if (! die && in_lto_p + /* Function scope variables are emitted when emitting the + DIE for the function. */ + && ! local_function_static (decl)) dwarf2out_decl (decl); else if (die) { |