From patchwork Thu Nov 18 21:11:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 72149 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 BC11CB71D1 for ; Fri, 19 Nov 2010 08:12:04 +1100 (EST) Received: (qmail 11068 invoked by alias); 18 Nov 2010 21:12:03 -0000 Received: (qmail 11058 invoked by uid 22791); 18 Nov 2010 21:12:01 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Nov 2010 21:11:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAILBtOG025559 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Nov 2010 16:11:56 -0500 Received: from anchor.twiddle.home (ovpn-113-101.phx2.redhat.com [10.3.113.101]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAILBtC7009190 for ; Thu, 18 Nov 2010 16:11:55 -0500 Message-ID: <4CE5969B.5010900@redhat.com> Date: Thu, 18 Nov 2010 13:11:55 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Thunderbird/3.1.6 MIME-Version: 1.0 To: GCC Patches Subject: fix pr 46515 X-IsSubscribed: yes 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 This PR has to do with replacing an insn that is FRAME_RELATED_P, and the replacement not being a member of epilogue_insn_hash. Which meant that we didn't re-position the EPILOGUE_BEG note properly, which meant that we emitted a DW_CFA_remember_state opcode at the wrong place. In theory something similar could happen with prologue insns, particularly with non-dwarf2 unwind info, such as ia64 or seh that have special directives that mark the end of the prologue. Tested on x86_64-linux. Committed. r~ PR middle-end/46515 * function.c (maybe_copy_prologue_epilogue_insn): Rename from maybe_copy_epilogue_insn; handle prologue insns as well. * rtl.h, cfglayout.c: Update for rename. * recog.c (peep2_attempt): Copy prologue/epilogue data for RTX_FRAME_RELATED_P insns. diff --git a/gcc/cfglayout.c b/gcc/cfglayout.c index be99991..e883af4 100644 --- a/gcc/cfglayout.c +++ b/gcc/cfglayout.c @@ -1179,7 +1179,7 @@ duplicate_insn_chain (rtx from, rtx to) || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC) break; copy = emit_copy_of_insn_after (insn, get_last_insn ()); - maybe_copy_epilogue_insn (insn, copy); + maybe_copy_prologue_epilogue_insn (insn, copy); break; case CODE_LABEL: diff --git a/gcc/function.c b/gcc/function.c index b9805dc..0ed674d 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5140,19 +5140,25 @@ record_insns (rtx insns, rtx end, htab_t *hashp) } } -/* INSN has been duplicated as COPY, as part of duping a basic block. - If INSN is an epilogue insn, then record COPY as epilogue as well. */ +/* INSN has been duplicated or replaced by as COPY, perhaps by duplicating a + basic block, splitting or peepholes. If INSN is a prologue or epilogue + insn, then record COPY as well. */ void -maybe_copy_epilogue_insn (rtx insn, rtx copy) +maybe_copy_prologue_epilogue_insn (rtx insn, rtx copy) { + htab_t hash; void **slot; - if (epilogue_insn_hash == NULL - || htab_find (epilogue_insn_hash, insn) == NULL) - return; + hash = epilogue_insn_hash; + if (!hash || !htab_find (hash, insn)) + { + hash = prologue_insn_hash; + if (!hash || !htab_find (hash, insn)) + return; + } - slot = htab_find_slot (epilogue_insn_hash, copy, INSERT); + slot = htab_find_slot (hash, copy, INSERT); gcc_assert (*slot == NULL); *slot = copy; } diff --git a/gcc/recog.c b/gcc/recog.c index b140c0e..edbf82b 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -3219,6 +3219,10 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) if (!new_set || !rtx_equal_p (new_set, old_set)) add_reg_note (new_insn, REG_FRAME_RELATED_EXPR, old_set); } + + /* Copy prologue/epilogue status. This is required in order to keep + proper placement of EPILOGUE_BEG and the DW_CFA_remember_state. */ + maybe_copy_prologue_epilogue_insn (old_insn, new_insn); } /* If we are splitting a CALL_INSN, look for the CALL_INSN diff --git a/gcc/rtl.h b/gcc/rtl.h index 745d6f4..ab215d6 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2411,7 +2411,7 @@ extern int prologue_epilogue_contains (const_rtx); extern int sibcall_epilogue_contains (const_rtx); extern void mark_temp_addr_taken (rtx); extern void update_temp_slot_address (rtx, rtx); -extern void maybe_copy_epilogue_insn (rtx, rtx); +extern void maybe_copy_prologue_epilogue_insn (rtx, rtx); /* In stmt.c */ extern void expand_null_return (void);