From patchwork Wed Oct 5 15:59:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 117884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8D940B6F6B for ; Thu, 6 Oct 2011 02:59:55 +1100 (EST) Received: (qmail 22958 invoked by alias); 5 Oct 2011 15:59:53 -0000 Received: (qmail 22945 invoked by uid 22791); 5 Oct 2011 15:59:52 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Oct 2011 15:59:25 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1RBTsR-0005hm-7c from Bernd_Schmidt@mentor.com ; Wed, 05 Oct 2011 08:59:23 -0700 Received: from [127.0.0.1] ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Oct 2011 16:59:21 +0100 Message-ID: <4E8C7ED0.3090705@codesourcery.com> Date: Wed, 05 Oct 2011 17:59:12 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110920 Lightning/1.0b3pre Thunderbird/3.1.12 MIME-Version: 1.0 To: Richard Guenther CC: Richard Henderson , GCC Patches , richard.sandiford@linaro.org Subject: Re: Initial shrink-wrapping patch References: <4E5E7342.9050103@codesourcery.com> <4E6E9857.50600@t-online.de> <4E6F37D9.9000108@t-online.de> <4E6F4B90.2050408@codesourcery.com> <4E6F786E.6080407@codesourcery.com> <4E712FD6.5030109@redhat.com> <4E8239ED.9020004@codesourcery.com> <4E85F395.3030006@redhat.com> <4E8B8469.2090605@codesourcery.com> <4E8B88E7.3090107@redhat.com> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 10/05/11 17:13, Richard Guenther wrote: > On Wed, Oct 5, 2011 at 12:29 AM, Richard Henderson 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)