https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101905
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- I think adding the location early is most sensible in this case. As you saw that might need tickling down adjustments or maybe a special-case of DECL_REGISTER globals, bypassing most of the add_location_or_const_value_attribute magic.