From patchwork Fri Oct 16 08:01:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 531083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (unknown [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CD2E71402B6 for ; Fri, 16 Oct 2015 19:04:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uY5+THml; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=iBmVSRxg2GS3QC4wR fSi4rdpIsX+SSUBQV+qupgMHlcjEyosS6f6No9Bd0hwojjiZ52suBkegBPCgqoYH aveSL9yCoH1gqND28HtRcAXtTdXIPyTshStUsWsuyCzYjA4FyAqAJWEmZBMvqax4 7SXganVAMwQhTW09BMNxewVmIE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=oHGTdncvY8iTWjApB/GHZWA w3mY=; b=uY5+THmlb0oQMpwCsis6gd0QrkCU958v7+bZ5KbMH6LctN7XFVbbJx5 GDgjvXkikDlkNV6iJOeOZnCnFQbGqIGctvnPjVJ8Yqm5MYGSiNlnIRtkSuhzO2p/ P3HEIoKSXOrWQPj3Xw9iXALF+DdNIgjaFE0GmtokC9fRO8sklpDg= Received: (qmail 18493 invoked by alias); 16 Oct 2015 08:03:49 -0000 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 Received: (qmail 18476 invoked by uid 89); 16 Oct 2015 08:03:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS autolearn=no version=3.3.2 X-HELO: mx07-00178001.pphosted.com Received: from Unknown (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 16 Oct 2015 08:01:42 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id t9G7xnNQ010464; Fri, 16 Oct 2015 10:01:32 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 1xjbk3vam3-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Oct 2015 10:01:32 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4AFFC43; Fri, 16 Oct 2015 08:01:08 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DD54EA510; Fri, 16 Oct 2015 08:01:29 +0000 (GMT) Received: from [164.129.122.197] (164.129.122.197) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.389.2; Fri, 16 Oct 2015 10:01:29 +0200 Subject: refactoring TARGET_PTRMEMFUNC_VBIT_LOCATION checks To: Bernd Schmidt , "law@redhat.com" References: <560A90F2.5010708@st.com> <560C31CD.7060009@redhat.com> <560CDCD7.9080108@st.com> <560D5B36.2020600@st.com> <5614C412.5080400@st.com> <5614F17B.5060402@redhat.com> <5614F7D0.8010409@st.com> <56155841.6000404@redhat.com> <56155B72.4020807@redhat.com> <56166C36.7040600@st.com> <56166DA5.3030909@redhat.com> <561674C1.8030008@st.com> <56167E09.3010502@redhat.com> <561B91DE.5040909@st.com> <561B973F.90302@redhat.com> CC: "gcc-patches@gcc.gnu.org" From: Christian Bruel X-No-Archive: yes Message-ID: <5620AED8.4000805@st.com> Date: Fri, 16 Oct 2015 10:01:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <561B973F.90302@redhat.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-10-16_05:2015-10-15, 2015-10-16, 1970-01-01 signatures=0 X-IsSubscribed: yes Hello, On 10/12/2015 01:19 PM, Bernd Schmidt wrote: > On 10/12/2015 12:56 PM, Christian Bruel wrote: >> yes I see, I was hoping to avoid a new hook, but as you said it seems >> mandatory for the mere declaration case. >> >> Here is one proposal, it defaults to nothing and the ARM implementation >> does not need to handle the vptr bit setting. so that simplifies a lot >> the things. >> >> The hook is called from rest_of_decl_compilation for mere declarations >> and allocate_struct_function for definitions. > > This looks good to me. I still think we also want your vptr patch. > > Bernd > Here is the "vptr patch". 2 changes to watch for the review : - I replaced the DECL_ALIGN checks by FUNCTION_BOUNDARY because there is no user align at that time of processing and it's consistent with the default TARGET_PTRMEMFUNC_VBIT_LOCATION macro implementation (or TARGET_PTRMEMFUNC_VBIT_LOCATION should also be function of DECL_ALIGN) - The second chunk from cp/lambda.c did not seem to be needed (?). Thunks are FUNCTION_TYPE and I don't see why they would need to carry the vptr bit information (for METHOD_TYPE from my understanding). Or did I miss something here ? bootstrapped on x86. no c/c++ new failures for x86 (ptrmemfunc_vbit_in_pfn, align 8) arm (ptrmemfunc_vbit_in_delta, align 16 or 32) sh4 (ptrmemfunc_vbit_in_pfn, align 16) It's a code cleanup/refactoring. No new testcase. thanks 2015-09-29 Christian Bruel * function.h (MINIMUM_METHOD_BOUNDARY): New macro. * cp/decl.c (grokfndecl): Set DECL_ALIGN with MINIMUM_METHOD_BOUNDARY. * cp/method.c (implicitly_declare_fn): Likewise. * cp/lambda.c (maybe_add_lambda_conv_op): Likewise, remove wrong setting. * java/class.c (add_method_1): Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 228756) +++ cp/decl.c (working copy) @@ -7826,6 +7826,8 @@ grokfndecl (tree ctype, parm = build_this_parm (type, quals); DECL_CHAIN (parm) = parms; parms = parm; + + /* Allocate space to hold the vptr bit if needed. */ + DECL_ALIGN (decl) = MINIMUM_METHOD_BOUNDARY; } DECL_ARGUMENTS (decl) = parms; for (t = parms; t; t = DECL_CHAIN (t)) @@ -7849,14 +7851,6 @@ grokfndecl (tree ctype, break; } - /* If pointers to member functions use the least significant bit to - indicate whether a function is virtual, ensure a pointer - to this function will have that bit clear. */ - if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn - && TREE_CODE (type) == METHOD_TYPE - && DECL_ALIGN (decl) < 2 * BITS_PER_UNIT) - DECL_ALIGN (decl) = 2 * BITS_PER_UNIT; - if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR) { Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 228756) +++ cp/lambda.c (working copy) @@ -1006,11 +1006,8 @@ maybe_add_lambda_conv_op (tree type) tree convfn = build_lang_decl (FUNCTION_DECL, name, fntype); tree fn = convfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); - - if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn - && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) - DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; - + DECL_ALIGN (fn) = MINIMUM_METHOD_BOUNDARY; SET_OVERLOADED_OPERATOR_CODE (fn, TYPE_EXPR); grokclassfn (type, fn, NO_SPECIAL); set_linkage_according_to_type (type, fn); @@ -1042,9 +1039,7 @@ maybe_add_lambda_conv_op (tree type) tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype); fn = statfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); - if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn - && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) - DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; grokclassfn (type, fn, NO_SPECIAL); set_linkage_according_to_type (type, fn); rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof); Index: cp/method.c =================================================================== --- cp/method.c (revision 228756) +++ cp/method.c (working copy) @@ -1849,13 +1849,9 @@ implicitly_declare_fn (special_function_ DECL_ASSIGNMENT_OPERATOR_P (fn) = 1; SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR); } - - /* If pointers to member functions use the least significant bit to - indicate whether a function is virtual, ensure a pointer - to this function will have that bit clear. */ - if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn - && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) - DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; + + DECL_ALIGN (fn) = MINIMUM_METHOD_BOUNDARY; /* Create the explicit arguments. */ if (rhs_parm_type) Index: function.h =================================================================== --- function.h (revision 228756) +++ function.h (working copy) @@ -537,6 +537,13 @@ do { \ #define ASLK_REDUCE_ALIGN 1 #define ASLK_RECORD_PAD 2 +/* If pointers to member functions use the least significant bit to + indicate whether a function is virtual, ensure a pointer + to this function will have that bit clear. */ +#define MINIMUM_METHOD_BOUNDARY \ + ((TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn) \ + ? MAX (FUNCTION_BOUNDARY, 2 * BITS_PER_UNIT) : FUNCTION_BOUNDARY) + extern void push_function_context (void); Index: java/class.c =================================================================== --- java/class.c (revision 228756) +++ java/class.c (working copy) @@ -779,13 +779,8 @@ add_method_1 (tree this_class, int acces DECL_CHAIN (fndecl) = TYPE_METHODS (this_class); TYPE_METHODS (this_class) = fndecl; - /* If pointers to member functions use the least significant bit to - indicate whether a function is virtual, ensure a pointer - to this function will have that bit clear. */ - if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn - && !(access_flags & ACC_STATIC) - && DECL_ALIGN (fndecl) < 2 * BITS_PER_UNIT) - DECL_ALIGN (fndecl) = 2 * BITS_PER_UNIT; + if (!(access_flags & ACC_STATIC)) + DECL_ALIGN (fndecl) = MINIMUM_METHOD_BOUNDARY; /* Notice that this is a finalizer and update the class type accordingly. This is used to optimize instance allocation. */