2009-07-02 Jakub Jelinek PR debug/40596 * dwarf2out.c (dwarf2out_begin_epilogue): Copy cfa into cfa_remember even if no insns are present after epilogue. (dwarf2out_end_epilogue): If cfa_remember.in_use, copy if back to cfa and clear its in_use flag. --- gcc/dwarf2out.c.jj 2009-06-30 18:18:50.000000000 +0200 +++ gcc/dwarf2out.c 2009-07-02 13:01:45.000000000 +0200 @@ -2773,7 +2773,15 @@ dwarf2out_begin_epilogue (rtx insn) gcc_assert (i != NULL); i = next_real_insn (i); if (i == NULL) - return; + { + /* Remember cfa state before epilogue anyway, so that + dwarf2out_end_epilogue can restore the CFA variable to cfa state + in the middle of function for later use by debug info. */ + gcc_assert (!cfa_remember.in_use); + cfa_remember = cfa; + cfa_remember.in_use = 1; + return; + } /* Insert the restore before that next real insn in the stream, and before a potential NOTE_INSN_EPILOGUE_BEG -- we do need these notes to be @@ -3710,6 +3718,12 @@ dwarf2out_end_epilogue (unsigned int lin fde = current_fde (); gcc_assert (fde != NULL); fde->dw_fde_end = xstrdup (label); + + if (cfa_remember.in_use) + { + cfa = cfa_remember; + cfa_remember.in_use = 0; + } } void