From patchwork Tue May 15 12:07:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 913584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477701-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UWU6yiV1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [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 40lbtj0Txvz9ryk for ; Tue, 15 May 2018 22:08:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=fZpINuqHeDkxI0VP356etVGS5V49jbWE1jSLdjMCgRuyTby0mZ m3pLq5eNKFdKINJF3VgR1jqWsfQ4Dj/O1GO3DtfFpp9/v2922GsFJlJ2u9ULUPyM JPjS7YwIo84RNQ2mOw4C9x3H6NPiohlnsolY6yEJ8+s11K+pqak7JhrFw= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=6HXnNUDDBcZi29ewgwN7Cl5W0mk=; b=UWU6yiV1GHQed4UVOuIk A3/XVFxO/NG2x3jFsEJht68em+EbuAWdxYnE264vLh1XJmklQwn8gLSNPfip23JP Ko9URDrgX+L0Rf/tHofN94HN8TMiL5BlJwMMJtG0t/JxNEy6XCSE2zWFgms3epGV 9SGT5LVgOX50ZzX9HuVc9vI= Received: (qmail 38292 invoked by alias); 15 May 2018 12:08:05 -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 38278 invoked by uid 89); 15 May 2018 12:08:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 May 2018 12:08:03 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4FC5ukk185535; Tue, 15 May 2018 12:08:01 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2hx29w01h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 May 2018 12:08:01 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4FC80ai002958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 May 2018 12:08:01 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4FC80gR022659; Tue, 15 May 2018 12:08:00 GMT Received: from [192.168.1.4] (/95.235.218.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 May 2018 05:07:47 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Add DECL_MAYBE_IN_CHARGE_CDTOR_P Message-ID: Date: Tue, 15 May 2018 14:07:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8893 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805150126 X-IsSubscribed: yes Hi, noticed a few times while working on various issues, maybe we want to add the macro now? Tested x86_64-linux. Thanks, Paolo. //////////////////// 2018-05-15 Paolo Carlini * cp-tree.h (DECL_MAYBE_IN_CHARGE_CDTOR_P): New. (FOR_EACH_CLONE): Update. * decl.c (grokdeclarator): Use it. * decl2.c (vague_linkage_p): Likewise. * mangle.c (mangle_decl): Likewise. * method.c (lazily_declare_fn): Likewise. * optimize.c (can_alias_cdtor, maybe_clone_body): Likewise. * repo.c (repo_emit_p): Likewise. * tree.c (decl_linkage): Likewise. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 260252) +++ cp-tree.h (working copy) @@ -2783,6 +2783,12 @@ struct GTY(()) lang_decl { #define DECL_DELETING_DESTRUCTOR_P(NODE) \ (DECL_NAME (NODE) == deleting_dtor_identifier) +/* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or + DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */ +#define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \ + (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \ + || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE)) + /* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or destructor. */ #define DECL_CLONED_FUNCTION_P(NODE) (!!decl_cloned_function_p (NODE, true)) @@ -2800,8 +2806,7 @@ struct GTY(()) lang_decl { */ #define FOR_EACH_CLONE(CLONE, FN) \ if (!(TREE_CODE (FN) == FUNCTION_DECL \ - && (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN) \ - || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\ + && DECL_MAYBE_IN_CHARGE_CDTOR_P (FN))) \ ; \ else \ for (CLONE = DECL_CHAIN (FN); \ Index: decl.c =================================================================== --- decl.c (revision 260252) +++ decl.c (working copy) @@ -11721,9 +11721,7 @@ grokdeclarator (const cp_declarator *declarator, { if (!current_function_decl) DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); - else if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (current_function_decl) - || (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P - (current_function_decl))) + else if (DECL_MAYBE_IN_CHARGE_CDTOR_P (current_function_decl)) /* The TYPE_DECL is "abstract" because there will be clones of this constructor/destructor, and there will be copies of this TYPE_DECL generated in those Index: decl2.c =================================================================== --- decl2.c (revision 260252) +++ decl2.c (working copy) @@ -1933,8 +1933,7 @@ vague_linkage_p (tree decl) maybe-in-charge 'tor variants; in that case we need to check one of the "clones" for the real linkage. But only in that case; before maybe_clone_body we haven't yet copied the linkage to the clones. */ - if ((DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl) - || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)) + if (DECL_MAYBE_IN_CHARGE_CDTOR_P (decl) && !DECL_ABSTRACT_P (decl) && DECL_CHAIN (decl) && DECL_CLONED_FUNCTION_P (DECL_CHAIN (decl))) Index: mangle.c =================================================================== --- mangle.c (revision 260252) +++ mangle.c (working copy) @@ -3862,8 +3862,7 @@ mangle_decl (const tree decl) if (id != DECL_NAME (decl) /* Don't do this for a fake symbol we aren't going to emit anyway. */ && TREE_CODE (decl) != TYPE_DECL - && !DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) - && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) + && !DECL_MAYBE_IN_CHARGE_CDTOR_P (decl)) { int save_ver = flag_abi_version; tree id2 = NULL_TREE; Index: method.c =================================================================== --- method.c (revision 260252) +++ method.c (working copy) @@ -2422,8 +2422,7 @@ lazily_declare_fn (special_function_kind sfk, tree fixup_type_variants (type); maybe_add_class_template_decl_list (type, fn, /*friend_p=*/0); - if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn) - || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)) + if (DECL_MAYBE_IN_CHARGE_CDTOR_P (fn)) /* Create appropriate clones. */ clone_function_decl (fn, /*update_methods=*/true); Index: optimize.c =================================================================== --- optimize.c (revision 260252) +++ optimize.c (working copy) @@ -194,8 +194,7 @@ can_alias_cdtor (tree fn) /* ??? Why not use aliases with -frepo? */ if (flag_use_repository) return false; - gcc_assert (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn) - || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)); + gcc_assert (DECL_MAYBE_IN_CHARGE_CDTOR_P (fn)); /* Don't use aliases for weak/linkonce definitions unless we can put both symbols in the same COMDAT group. */ return (DECL_INTERFACE_KNOWN (fn) @@ -440,8 +439,7 @@ maybe_clone_body (tree fn) bool need_alias = false; /* We only clone constructors and destructors. */ - if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn) - && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)) + if (!DECL_MAYBE_IN_CHARGE_CDTOR_P (fn)) return 0; populate_clone_array (fn, fns); Index: repo.c =================================================================== --- repo.c (revision 260252) +++ repo.c (working copy) @@ -330,8 +330,7 @@ repo_emit_p (tree decl) /* For constructors and destructors, the repository contains information about the clones -- not the original function -- because only the clones are emitted in the object file. */ - if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) - || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) + if (DECL_MAYBE_IN_CHARGE_CDTOR_P (decl)) { int emit_p = 0; tree clone; Index: tree.c =================================================================== --- tree.c (revision 260252) +++ tree.c (working copy) @@ -5012,8 +5012,7 @@ decl_linkage (tree decl) /* maybe_thunk_body clears TREE_PUBLIC on the maybe-in-charge 'tor variants, check one of the "clones" for the real linkage. */ - if ((DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl) - || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)) + if (DECL_MAYBE_IN_CHARGE_CDTOR_P (decl) && DECL_CHAIN (decl) && DECL_CLONED_FUNCTION_P (DECL_CHAIN (decl))) return decl_linkage (DECL_CHAIN (decl));