On 10/05/11 17:13, Richard Guenther wrote: > On Wed, Oct 5, 2011 at 12:29 AM, Richard Henderson <r...@redhat.com> wrote: >> On 10/04/2011 03:10 PM, Bernd Schmidt wrote: >>> * doc/invoke.texi (-fshrink-wrap): Document. >>> * opts.c (default_options_table): Add it. >>> * common.opt (fshrink-wrap): Add. >>> * function.c (emit_return_into_block): Remove useless declaration. >>> (record_hard_reg_uses_1, record_hard_reg_uses, frame_required_for_rtx, >>> requires_stack_frame_p, gen_return_pattern): New static functions. >>> (emit_return_into_block): New arg simple_p. All callers changed. >>> Use gen_return_pattern. >>> (thread_prologue_and_epilogue_insns): Implement shrink-wrapping. >>> * config/i386/i386.md (return): Expand into a simple_return. >>> (simple_return): New expander): >>> (simple_return_internal, simple_return_internal_long, >>> simple_return_pop_internal_long, simple_return_indirect_internal): >>> Renamed from return_internal, return_internal_long, >>> return_pop_internal_long and return_indirect_internal; changed to use >>> simple_return. >>> * config/i386/i386.c (ix86_expand_epilogue): Adjust to expand >>> simple returns. >>> (ix86_pad_returns): Likewise. >>> * function.h (struct rtl_data): Add member shrink_wrapped. >>> * cfgcleanup.c (outgoing_edges_match): If shrink-wrapped, edges that >>> are not jumps or sibcalls can't be compared. >>> >>> * gcc.target/i386/sw-1.c: New test. >> >> Ok. >> >> As a followup, I think this option needs to be disabled for profiling >> and profile_after_prologue. Should be a mere matter of frobbing the >> options at startup. > > This breaks bootstrap on x86_64-linux. > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50621
Caused by the x86_64 expand_epilogue not generating REG_CFA_RESTORE notes, and in another case by queuing but not emitting them. Bootstrapping the following now. Ok? (Alternatively, could keep the redzone logic, but make it depend on !flag_shrink_wrap). Bernd
* config/i386/i386.c (ix86_add_cfa_restore_note): Lose CFA_OFFSET argument. All callers changed. Always emit a note. (ix86_expand_epilogue): Ensure queued cfa_adjust notes are attached to an insn. Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 179553) +++ gcc/config/i386/i386.c (working copy) @@ -9126,17 +9126,11 @@ ix86_emit_save_sse_regs_using_mov (HOST_ static GTY(()) rtx queued_cfa_restores; /* Add a REG_CFA_RESTORE REG note to INSN or queue them until next stack - manipulation insn. The value is on the stack at CFA - CFA_OFFSET. - Don't add the note if the previously saved value will be left untouched - within stack red-zone till return, as unwinders can find the same value - in the register and on the stack. */ + manipulation insn. */ static void -ix86_add_cfa_restore_note (rtx insn, rtx reg, HOST_WIDE_INT cfa_offset) +ix86_add_cfa_restore_note (rtx insn, rtx reg) { - if (cfa_offset <= cfun->machine->fs.red_zone_offset) - return; - if (insn) { add_reg_note (insn, REG_CFA_RESTORE, reg); @@ -10298,7 +10292,7 @@ ix86_emit_restore_reg_using_pop (rtx reg struct machine_function *m = cfun->machine; rtx insn = emit_insn (gen_pop (reg)); - ix86_add_cfa_restore_note (insn, reg, m->fs.sp_offset); + ix86_add_cfa_restore_note (insn, reg); m->fs.sp_offset -= UNITS_PER_WORD; if (m->fs.cfa_reg == crtl->drap_reg @@ -10383,8 +10377,7 @@ ix86_emit_leave (void) add_reg_note (insn, REG_CFA_DEF_CFA, plus_constant (stack_pointer_rtx, m->fs.sp_offset)); RTX_FRAME_RELATED_P (insn) = 1; - ix86_add_cfa_restore_note (insn, hard_frame_pointer_rtx, - m->fs.fp_offset); + ix86_add_cfa_restore_note (insn, hard_frame_pointer_rtx); } } @@ -10421,7 +10414,7 @@ ix86_emit_restore_regs_using_mov (HOST_W m->fs.drap_valid = true; } else - ix86_add_cfa_restore_note (NULL_RTX, reg, cfa_offset); + ix86_add_cfa_restore_note (NULL_RTX, reg); cfa_offset -= UNITS_PER_WORD; } @@ -10446,7 +10439,7 @@ ix86_emit_restore_sse_regs_using_mov (HO set_mem_align (mem, 128); emit_move_insn (reg, mem); - ix86_add_cfa_restore_note (NULL_RTX, reg, cfa_offset); + ix86_add_cfa_restore_note (NULL_RTX, reg); cfa_offset -= 16; } @@ -10738,6 +10731,8 @@ ix86_expand_epilogue (int style) GEN_INT (m->fs.sp_offset - UNITS_PER_WORD), style, true); } + else + ix86_add_queued_cfa_restore_notes (get_last_insn ()); /* Sibcall epilogues don't want a return instruction. */ if (style == 0)