From patchwork Wed Sep 22 22:03:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 65465 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 E0B19B70DA for ; Thu, 23 Sep 2010 08:03:52 +1000 (EST) Received: (qmail 31128 invoked by alias); 22 Sep 2010 22:03:50 -0000 Received: (qmail 31110 invoked by uid 22791); 22 Sep 2010 22:03:49 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Sep 2010 22:03:45 +0000 Received: from kpbe11.cbf.corp.google.com (kpbe11.cbf.corp.google.com [172.25.105.75]) by smtp-out.google.com with ESMTP id o8MM3g8w024225 for ; Wed, 22 Sep 2010 15:03:42 -0700 Received: from iwn40 (iwn40.prod.google.com [10.241.68.104]) by kpbe11.cbf.corp.google.com with ESMTP id o8MM3A9Q018961 for ; Wed, 22 Sep 2010 15:03:40 -0700 Received: by iwn40 with SMTP id 40so220993iwn.38 for ; Wed, 22 Sep 2010 15:03:40 -0700 (PDT) Received: by 10.231.33.203 with SMTP id i11mr482991ibd.8.1285193015544; Wed, 22 Sep 2010 15:03:35 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-123-203.mtv.corp.google.com [172.22.123.203]) by mx.google.com with ESMTPS id n20sm40664ibe.5.2010.09.22.15.03.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 22 Sep 2010 15:03:34 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: PATCH RFA: Split stack [4/7]: REF_CFA_TEMPORARY Date: Wed, 22 Sep 2010 15:03:32 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true 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 is the fourth of the -fsplit-stack patches. This patch adds a new feature to the DWARF frame note. If an insn has a new REG_CFA_TEMPORARY note, then the CFA is set to the value of the note only for that insn. The i386 backend uses this new feature to set the unwind information for a special ret instruction that it uses to permit the processor to do call/return prediction. This patch is in the middle-end and as such does not require approval, but as it is somewhat unrelated to the rest of the patches I am separating it out for possible comment. Ian 2010-09-21 Ian Lance Taylor * reg-notes.def (CFA_TEMPORARY): New note. * dwarf2out.c (dwarf2out_frame_debug): Handle REG_CFA_TEMPORARY. (dwarf2out_cfi_begin_epilogue): Call dwarf2out_frame_debug_remember_state. (dwarf2out_frame_debug_remember_state): New static function, broken out of dwarf2out_cfi_begin_epilogue. Index: gcc/reg-notes.def =================================================================== --- gcc/reg-notes.def (revision 164490) +++ gcc/reg-notes.def (working copy) @@ -165,6 +165,13 @@ REG_NOTE (CFA_RESTORE) to the argument, if it is a MEM, it is ignored. */ REG_NOTE (CFA_SET_VDRAP) +/* Temporarily set the CFA for just one insn. This saves the old + state, sets the CFA, and then restores the state after the insn. + The pattern for this note is the new CFA value. This is used by + the split stack code to support unwinding through the call into the + split stack routine. */ +REG_NOTE (CFA_TEMPORARY) + /* Indicates that REG holds the exception context for the function. This context is shared by inline functions, so the code to acquire the real exception context is delayed until after inlining. */ Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 164490) +++ gcc/dwarf2out.c (working copy) @@ -473,6 +473,7 @@ static void output_call_frame_info (int) static void dwarf2out_note_section_used (void); static bool clobbers_queued_reg_save (const_rtx); static void dwarf2out_frame_debug_expr (rtx, const char *); +static void dwarf2out_frame_debug_remember_state (void); /* Support for complex CFA locations. */ static void output_cfa_loc (dw_cfi_ref); @@ -2832,6 +2833,17 @@ dwarf2out_frame_debug (rtx insn, bool af handled_one = true; break; + case REG_CFA_TEMPORARY: + if (!after_p) + { + dwarf2out_frame_debug_remember_state (); + dwarf2out_frame_debug_def_cfa (XEXP (note, 0), label); + } + else + dwarf2out_frame_debug_restore_state (); + handled_one = true; + break; + default: break; } @@ -2924,9 +2936,17 @@ dwarf2out_cfi_begin_epilogue (rtx insn) } emit_note_before (NOTE_INSN_CFA_RESTORE_STATE, i); + dwarf2out_frame_debug_remember_state (); +} + +/* Remember the current state. */ + +static void +dwarf2out_frame_debug_remember_state (void) +{ emit_cfa_remember = true; - /* And emulate the state save. */ + /* Emulate the state save. */ gcc_assert (!cfa_remember.in_use); cfa_remember = cfa; cfa_remember.in_use = 1;