From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27942 invoked by alias); 8 May 2014 14:25:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27928 invoked by uid 89); 8 May 2014 14:25:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 May 2014 14:25:05 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s48EP1OA019797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 May 2014 10:25:02 -0400 Received: from [10.36.5.192] (vpn1-5-192.ams2.redhat.com [10.36.5.192]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s48EOxVr009494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 8 May 2014 10:25:00 -0400 Message-ID: <536B93BB.8050805@redhat.com> Date: Thu, 08 May 2014 14:25:00 -0000 From: Nicholas Clifton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Mike Stump CC: Jakub Jelinek , gcc-patches Subject: Re: RFA: Fix calculation of size of builtin setjmp buffer References: <87wqdzjccp.fsf@redhat.com> <20140506131536.GV1817@tucnak.redhat.com> <5368F2FD.9080604@redhat.com> <20140506144026.GX1817@tucnak.redhat.com> <5368FAA9.1030304@redhat.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070209040508070406080304" X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00490.txt.bz2 This is a multi-part message in MIME format. --------------070209040508070406080304 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 553 Hi Mike, > How about GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)) / GET_MODE_SIZE (Pmode) + 2 + /* slop for mips, see builtin_setjmp_setup */ 1 - 1. This retains the slop for mips, and fixes ports like ia64 and s390 (see STACK_SAVEAREA_MODE on those ports, it is larger one might expect)? OK - revised patch attached. I have added a comment before the computation to explain each of the numbers, and adjusted the comments in the other files to match the new size of the jump buffer. What do you think of this version ? Cheers Nick --------------070209040508070406080304 Content-Type: application/x-troff-man; name="builtin-setjmp.patch.2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="builtin-setjmp.patch.2" Content-length: 4656 Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 210203) +++ gcc/builtins.c (working copy) @@ -984,10 +984,10 @@ emit_insn (gen_blockage ()); } -/* __builtin_longjmp is passed a pointer to an array of five words (not - all will be used on all machines). It operates similarly to the C - library function of the same name, but is more efficient. Much of - the code below is copied from the handling of non-local gotos. */ +/* __builtin_longjmp is passed a pointer to an array of ~4 pointer sized + entries, not all will be used on all machines. It operates similarly + to the C library function of the same name, but is more efficient. Much + of the code below is copied from the handling of non-local gotos. */ static void expand_builtin_longjmp (rtx buf_addr, rtx value) @@ -1211,10 +1211,10 @@ return const0_rtx; } -/* __builtin_update_setjmp_buf is passed a pointer to an array of five words - (not all will be used on all machines) that was passed to __builtin_setjmp. - It updates the stack pointer in that block to correspond to the current - stack pointer. */ +/* __builtin_update_setjmp_buf is passed a pointer to an array of ~4 + entries (not all will be used on all machines) that was passed to + __builtin_setjmp. It updates the stack pointer in that block to + correspond to the current stack pointer. */ static void expand_builtin_update_setjmp_buf (rtx buf_addr) @@ -6211,8 +6211,8 @@ gcc_unreachable (); case BUILT_IN_SETJMP_SETUP: - /* __builtin_setjmp_setup is passed a pointer to an array of five words - and the receiver label. */ + /* __builtin_setjmp_setup is passed a pointer to an array of ~4 + entries and the receiver label. */ if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { rtx buf_addr = expand_expr (CALL_EXPR_ARG (exp, 0), subtarget, @@ -6245,9 +6245,9 @@ } break; - /* __builtin_longjmp is passed a pointer to an array of five words. - It's similar to the C library longjmp function but works with - __builtin_setjmp above. */ + /* __builtin_longjmp is passed a pointer to an array of ~4 + entries. It's similar to the C library longjmp function + but works with __builtin_setjmp above. */ case BUILT_IN_LONGJMP: if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { Index: gcc/doc/md.texi =================================================================== --- gcc/doc/md.texi (revision 210203) +++ gcc/doc/md.texi (working copy) @@ -6112,10 +6112,15 @@ A typical reason why you might need this pattern is if some value, such as a pointer to a global table, must be restored. Though it is preferred that the pointer value be recalculated if possible (given the -address of a label for instance). The single argument is a pointer to -the @code{jmp_buf}. Note that the buffer is five words long and that -the first three are normally used by the generic mechanism. +address of a label for instance). +The single argument is a pointer to the @code{jmp_buf}. This buffer +is big enough to hold approximately 4 @code{Pmode} sized entries, +although the exact size is target dependent. The generic mechanism +uses three entries, (to hold the frame pointer, return address and +stack pointer respectively), but this pattern can make use of the +extra space if it so desires. + @cindex @code{builtin_setjmp_receiver} instruction pattern @item @samp{builtin_setjmp_receiver} This pattern, if defined, contains code needed at the site of a Index: gcc/except.c =================================================================== --- gcc/except.c (revision 210203) +++ gcc/except.c (working copy) @@ -286,8 +286,16 @@ tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1); #endif #else - /* builtin_setjmp takes a pointer to 5 words. */ - tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); + /* Compute a minimally sized jump buffer. We are going to store 2 + pointers in it (frame pointer and return address), plus whatever is + needed by emit_stack_save(SAVE_NONLOCAL). Plus for the MIPS we need + room to save the global pointer. For more discussion on this topic + see: http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00313.html. */ + tmp = size_int (GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)) + / GET_MODE_SIZE (Pmode) + + 2 /* Stack pointer and frame pointer. */ + + 1 /* Slop for mips. */ + - 1); #endif tmp = build_index_type (tmp); tmp = build_array_type (ptr_type_node, tmp); --------------070209040508070406080304--