From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3763 invoked by alias); 15 May 2014 07:56:28 -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 3682 invoked by uid 89); 15 May 2014 07:56:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 15 May 2014 07:56:27 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 5233E274C842; Thu, 15 May 2014 09:56:24 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ShIg4OpJPXeo; Thu, 15 May 2014 09:56:24 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5081F274C833; Thu, 15 May 2014 09:56:22 +0200 (CEST) From: Eric Botcazou To: Nicholas Clifton Cc: gcc-patches@gcc.gnu.org Subject: Re: RFA: Fix calculation of size of builtin setjmp buffer Date: Thu, 15 May 2014 07:56:00 -0000 Message-ID: <2347976.UgdYmbUUr8@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: <53737067.2030608@redhat.com> References: <87wqdzjccp.fsf@redhat.com> <3114307.feqyCiYPCg@polaris> <53737067.2030608@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-SW-Source: 2014-05/txt/msg01152.txt.bz2 > Ah - you are worried about the case where STACK_SAVEAREA_MODE() is > smaller than Pmode, yes ? No, simply that the modified formula is plain wrong. The code does: tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); tmp = build_index_type (tmp); tmp = build_array_type (ptr_type_node, tmp); so, in the end, the size of the buffer is: [(5 * BITS_PER_WORD / POINTER_SIZE - 1) + 1] * POINTER_SIZE which boilds down to: 5 * BITS_PER_WORD provided that POINTER_SIZE <= BITS_PER_WORD. So we have a problem if POINTER_SIZE > BITS_PER_WORD, in which case it's sufficient to use 5 * POINTER_SIZE instead. > OK then, how about this revised version of the patch where the size > computation is now: > > tmp = size_int (MAX (GET_MODE_SIZE (STACK_SAVEAREA_MODE > (SAVE_NONLOCAL)) > / GET_MODE_SIZE (Pmode), 1) > + 2 /* Stack pointer and frame pointer. */ > + 1 /* Slop for mips. */ > - 1); > > OK to apply ? No, that's too complicated and risky, just do the following: /* builtin_setjmp takes a pointer to 5 words or pointers. */ if (POINTER_SIZE > BITS_PER_WORD) tmp = size_int (4); else tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); which is simple and safe. -- Eric Botcazou