https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101905
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- --- gcc/dwarf2out.c.jj 2021-08-17 09:25:08.196923026 +0200 +++ gcc/dwarf2out.c 2021-08-18 23:18:56.284227245 +0200 @@ -24477,7 +24477,9 @@ gen_variable_die (tree decl, tree origin { if (early_dwarf) add_pubname (decl_or_origin, var_die); - else + if (!early_dwarf + || (DECL_HARD_REGISTER (decl_or_origin) + && TREE_STATIC (decl_or_origin))) add_location_or_const_value_attribute (var_die, decl_or_origin, decl == NULL); } isn't sufficient because add_location_or_const_value_attribute has an early exit for early_dwarf...