Message ID | 4af162bf22c8a405100c31f57ac2c3b0de9b721e.1470015604.git.segher@kernel.crashing.org |
---|---|
State | New |
Headers | show |
On 07/31/2016 07:42 PM, Segher Boessenkool wrote: > Deleting restores (before a noreturn) that are dead confuses dwarf2cfi. > > 2016-06-07 Segher Boessenkool <segher@kernel.crashing.org> > > * dce.c (delete_unmarked_insns): Don't delete instructions with > a REG_CFA_RESTORE note. I don't really understand this one. Why is the restore marked dead and why doesn't that happen for normal epilogues? Something wonky seems to be going on here. jeff
On Thu, Sep 08, 2016 at 11:50:56AM -0600, Jeff Law wrote: > On 07/31/2016 07:42 PM, Segher Boessenkool wrote: > >Deleting restores (before a noreturn) that are dead confuses dwarf2cfi. > > > >2016-06-07 Segher Boessenkool <segher@kernel.crashing.org> > > > > * dce.c (delete_unmarked_insns): Don't delete instructions with > > a REG_CFA_RESTORE note. > I don't really understand this one. Why is the restore marked dead and > why doesn't that happen for normal epilogues? Something wonky seems to > be going on here. Because it's not behind a NOTE_INSN_EPILOGUE_BEGIN it is not treated specially by DCE, like insns in "normal" epilogues are. It is marked dead because it *is* dead: the value in the callee-save register is not used by anything anymore (noreturn!) Segher
On 09/09/2016 09:51 AM, Segher Boessenkool wrote: > On Thu, Sep 08, 2016 at 11:50:56AM -0600, Jeff Law wrote: >> On 07/31/2016 07:42 PM, Segher Boessenkool wrote: >>> Deleting restores (before a noreturn) that are dead confuses dwarf2cfi. >>> >>> 2016-06-07 Segher Boessenkool <segher@kernel.crashing.org> >>> >>> * dce.c (delete_unmarked_insns): Don't delete instructions with >>> a REG_CFA_RESTORE note. >> I don't really understand this one. Why is the restore marked dead and >> why doesn't that happen for normal epilogues? Something wonky seems to >> be going on here. > > Because it's not behind a NOTE_INSN_EPILOGUE_BEGIN it is not treated > specially by DCE, like insns in "normal" epilogues are. Ohhhhh! While I don't see the special handling of things after NOTE_INSN_EPILOGUE_BEG, I do see this in df-scan.c: if (targetm.have_epilogue () && epilogue_completed) { /* Mark all call-saved registers that we actually used. */ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) if (df_regs_ever_live_p (i) && !LOCAL_REGNO (i) && !TEST_HARD_REG_BIT (regs_invalidated_by_call, i)) bitmap_set_bit (exit_block_uses, i); } Which then presumably gets used elsewhere when solving problems. I wonder if we need some kind of similar mechanism to make those registers appear to be live at the component epilogues. Jeff
diff --git a/gcc/dce.c b/gcc/dce.c index ea3fb00..d510287 100644 --- a/gcc/dce.c +++ b/gcc/dce.c @@ -587,6 +587,15 @@ delete_unmarked_insns (void) if (!dbg_cnt (dce)) continue; + if (crtl->shrink_wrapped_separate + && find_reg_note (insn, REG_CFA_RESTORE, NULL)) + { + if (dump_file) + fprintf (dump_file, "DCE: NOT deleting insn %d, it's a " + "callee-save restore\n", INSN_UID (insn)); + continue; + } + if (dump_file) fprintf (dump_file, "DCE: Deleting insn %d\n", INSN_UID (insn));