https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63546
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jan Hubicka from comment #3) > OK, the problem seems to be that dwarf2out tries to produce RTL for a > variable that is optimized out. This happens here: > > /* Try harder to get a rtl. If this symbol ends up not being emitted > in the current CU, resolve_addr will remove the expression referencing > it. */ > if (rtl == NULL_RTX > && TREE_CODE (decl) == VAR_DECL > && !DECL_EXTERNAL (decl) > && TREE_STATIC (decl) > && DECL_NAME (decl) > && !DECL_HARD_REGISTER (decl) > && DECL_MODE (decl) != VOIDmode) > { > rtl = make_decl_rtl_for_debug (decl); > if (!MEM_P (rtl) > || GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF > || SYMBOL_REF_DECL (XEXP (rtl, 0)) != decl) > rtl = NULL_RTX; > } > > producing RTL brings the function in, because it wants to work out its > section that breaks. I do not think dwarf2out really needs RTL for variable > that was never output. > > Shall we kludge around and make make_decl_rtl-for_debug to not ICE but > return sort of random RTL or shall we just prevent this path with > reference_to_unused check? > > For Martin and Trevor, I think safe workaround is to just comment out this > path. Commenting that out will severely decrease debug info quality. Yes, dwarf2out really needs a RTL for those, and some that will not affect -fcompare-debug, with the right (mangled?) name of the var and various other attributes on the MEM.