From patchwork Sun Aug 25 15:38:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 269708 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 863532C00B6 for ; Mon, 26 Aug 2013 01:38:21 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=Ebm42PCyoYDi+sl+K NNaPyIG8JA5ZS4inCkxeR6XAT9Nyr6bmtdeMyjLMZTTqIfBAYVtSncZpCTyRWBWR +PyqMWPiuUScCzrzoJhihIpoGzaP+xWGrVlILnKPpFgZiyO2ErLeW9X9YPjUsZFM tRA3qqN0J1ULQOkoVo+jPezjTQ= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=f0aDSw1AEYashKKS0OfZIy0 DJgA=; b=wv9alOaRe2utHWB3rkx1HoH9ckOhj7tMXe3dB4PBwKwELg0v74s5EHb TdUQInaMc3RTXF0NLtaxFMuwX4ah0+zMdN1OJCvUo5/5P341stFhc4IAvyPNHRr9 tHzXoMJVMpd9QHvn8FmvbVDCy7P8z6L/d2QS5GD2iPI5mYaDqn5I= Received: (qmail 23755 invoked by alias); 25 Aug 2013 15:38:13 -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 23743 invoked by uid 89); 25 Aug 2013 15:38:13 -0000 X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD autolearn=ham version=3.3.2 Received: from atrey.karlin.mff.cuni.cz (HELO atrey.karlin.mff.cuni.cz) (195.113.26.193) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 25 Aug 2013 15:38:12 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id E8C788153B; Sun, 25 Aug 2013 17:38:09 +0200 (CEST) Date: Sun, 25 Aug 2013 17:38:09 +0200 From: Jan Hubicka To: Jason Merrill Cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [C++ patch] Move FINAL flag to middle-end trees. Message-ID: <20130825153809.GC9318@atrey.karlin.mff.cuni.cz> References: <52162B9B.5060905@redhat.com> <20130822152254.GC19256@kam.mff.cuni.cz> <521769A8.3010204@redhat.com> <20130823135755.GB22972@kam.mff.cuni.cz> <521770DA.300@redhat.com> <20130823143616.GA27462@kam.mff.cuni.cz> <20130823145112.GC27462@kam.mff.cuni.cz> <52184F67.3020908@redhat.com> <20130824091811.GA30293@kam.mff.cuni.cz> <52192428.7020500@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <52192428.7020500@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) > On 08/24/2013 05:18 AM, Jan Hubicka wrote: > >In the next step I would like to introduce the DECL_CPP_CONSTRUCTOR/DESTRUCTOR macro. > >The catch I run into is that these flags are tested on TEMPLATE_DECL so the middle-end > >macro bombs on type checking. I wonder what is best approach here. > > I think fix the front end to use STRIP_TEMPLATE to make sure we're > checking/setting the flag on a FUNCTION_DECL. Thank you! I did not know the FUNCTION_DECLs are already there. The following patch seems to work. Of course if it seems cleaner, I can update the users of the CPP macros into the expanded variants. I want to have CPP in name in middle-end to signify that we actually understand language specific properties of these functions (so constructors/destructors in other languages probably don't want to do that). Bootstrapped/regtested ppc64-linux, OK? * tree.h (tree_decl_with_vis): Add cpp_constructor and cpp_destructor. (DECL_CPP_CONSTRUCTOR_P, DECL_CPP_DESTRUCTOR_P): New macros. * cp-tree.h (DECL_CONSTRUCTOR_P, DECL_DESTRUCTOR_P): Change to strip templates and set the middle-end flag. Index: tree.h =================================================================== --- tree.h (revision 201977) +++ tree.h (working copy) @@ -3232,8 +3232,12 @@ struct GTY(()) tree_decl_with_vis { /* Used by C++ only. Might become a generic decl flag. */ unsigned shadowed_for_var_p : 1; /* Belong to FUNCTION_DECL exclusively. */ + unsigned cpp_constructor : 1; + /* Belong to FUNCTION_DECL exclusively. */ + unsigned cpp_destructor : 1; + /* Belong to FUNCTION_DECL exclusively. */ unsigned final : 1; - /* 13 unused bits. */ + /* 11 unused bits. */ }; extern tree decl_debug_expr_lookup (tree); @@ -3483,6 +3487,18 @@ extern vec **decl_debug_arg #define DECL_FUNCTION_VERSIONED(NODE)\ (FUNCTION_DECL_CHECK (NODE)->function_decl.versioned_function) +/* In FUNCTION_DECL, this is set if this function is a C++ constructor. + Devirtualization machinery uses this knowledge for determing type of the + object constructed. Also we assume that constructor address is not + important. */ +#define DECL_CPP_CONSTRUCTOR_P(NODE)\ + (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cpp_constructor) + +/* In FUNCTION_DECL, this is set if this function is a C++ destructor. + Devirtualization machinery uses this to track types in destruction. */ +#define DECL_CPP_DESTRUCTOR_P(NODE)\ + (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cpp_destructor) + /* In FUNCTION_DECL that represent an virtual method this is set when the method is final. */ #define DECL_FINAL_P(NODE)\ Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 201977) +++ cp/cp-tree.h (working copy) @@ -2121,9 +2121,10 @@ struct GTY((variable_size)) lang_decl { #define SET_DECL_LANGUAGE(NODE, LANGUAGE) \ (DECL_LANG_SPECIFIC (NODE)->u.base.language = (LANGUAGE)) -/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */ +/* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function + is a constructor. */ #define DECL_CONSTRUCTOR_P(NODE) \ - (LANG_DECL_FN_CHECK (NODE)->constructor_attr) + DECL_CPP_CONSTRUCTOR_P (STRIP_TEMPLATE (NODE)) /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete object. */ @@ -2152,9 +2153,10 @@ struct GTY((variable_size)) lang_decl { #define DECL_MOVE_CONSTRUCTOR_P(NODE) \ (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE)) -/* Nonzero if NODE is a destructor. */ +/* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL) + is a destructor. */ #define DECL_DESTRUCTOR_P(NODE) \ - (LANG_DECL_FN_CHECK (NODE)->destructor_attr) + DECL_CPP_DESTRUCTOR_P (STRIP_TEMPLATE (NODE)) /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the specialized in-charge constructor, in-charge deleting constructor,