From patchwork Sat Jan 6 05:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6619741dyb; Fri, 5 Jan 2024 21:13:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGtGwoojZPcrbi/m+c56yQVpSy8zTEffUpikzZZXN7xggs76KsVcCHCv4ZBB2LUgx6UXaQ X-Received: by 2002:ac8:5fc7:0:b0:423:a89d:df9b with SMTP id k7-20020ac85fc7000000b00423a89ddf9bmr918829qta.61.1704518014404; Fri, 05 Jan 2024 21:13:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704518014; cv=pass; d=google.com; s=arc-20160816; b=SMdim9pqS5+gv3kNcOZf9/LpFtlL/sgaIw2K1p/mJNQEwHJnTfYdPeqdhblQtPIcYa dzuqve2RjAHUAedLc4OUV/yUb8Q5WGKaL2zT1HWAEpCoKcjyN8sVJKxGzkeTPgciO9bo x8WjAqmI7pGYHO+IXxSZCQ1B1d93f/P/LrGmgo570hqZW4myq62OEkebERvy+98niEh0 /69np916NKs+uJ7AeiZYLXDvqGcWXBB8N6sjsvLd0W9qr1AjwwFXKD4U2CGoeXPXhNS7 JZLWmx7NaU+FUdRFBk53zX90o8klldjPC/NKurdQLXkNM8x2iwzv6NBKhg6zm2r1k2CT hxKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=QWqcDDsvpPQz3IngPiRUA7yfNSdEkuyFpdH2VktCYog=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=l0pcyz/hHkK5dQI6Mf6l68IhTc6IQKQtDDkdD743UOHXppClu6h1GZ2nSETs8Ak9qG Nl1Li7S0uG1eYFV6bq9FqPMvSwPbMJbEMi+vO1YMTx1n46mkMSrUISS/Ly4AkQ1rMIAW +38QWlyCy+uqE8PewiDYtbq7Lub8Iiv9QA1jq4ctKgVifxZ595rjSgJOLsBXQN7+Gn6P Zcc9CJzAvjUGYb27oHQ6pIsrmJFKitZnu+h0rs1adQH8MjmazWzNrJO+tfPdp/kEU1jS lKU3CiI6Rwkea2vjx8wpC26oXzzrHBcF4qC+Nbiihw0C3hmRakoOWYqs6Py4uz/xDSMo 2OFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=I8qsm0pp; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o15-20020a05622a138f00b0042972d02212si3409663qtk.462.2024.01.05.21.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:13:34 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=I8qsm0pp; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 130D0384DEC5 for ; Sat, 6 Jan 2024 05:13:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 130D0384DEC5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704518014; bh=QWqcDDsvpPQz3IngPiRUA7yfNSdEkuyFpdH2VktCYog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=I8qsm0ppNx9HVoboQQdEcWwrlc0iq3lXtiUR/pC8Vt66V9d02SsrUhovQ3UTDiVyl xwrVa+4uTIkBPOsTinGzTyZmXxi6Jnr7UFTfGIzq1076uIQ/UUZbdAiW5aurNRZGLy JvTr4oDjFljdJfyWOQDufBCB705/mlkN0SBc7h1E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 66666385840B; Sat, 6 Jan 2024 05:09:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66666385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 66666385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517754; cv=none; b=RxsU8yG3l/I6t1veKOfkIvQKWmReluUalNyGrvkSBk0HjdO52B88TKY7BcXnT1FccyKa292tIlnDi9ZhLq/NgNjwEix44moUk33nkCFu8ZUJ89qmbcCAn9lqTNgNJNQCEvNJtS0TtMfJE+GjNIxh+tBpppk7Zu7166YNHY2egYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517754; c=relaxed/simple; bh=weTLtuG27MRFXuF3ON+hNebI/50A0suZKgrVbpE9hug=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=s+37S+gazW0tb3LF4BWcbUpIu3dI4Iqy0rY7L8VkMXUbUiPmPp3MjoeOHTadXq3PM1eyDP3FPfnyEuTiUP7hlNlcON9LfGqeyRV6sFvO/bg3+a8iV+OVvTpuMs4A6RdQetuOFU+HQtnUY5+kk588Uea4EU+absquaQd+Tbk/T+g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247480.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4065391c007227; Sat, 6 Jan 2024 05:09:12 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3veyyu82qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:09:11 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658gKF002805 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580H6000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 1/8] c++: Implement __is_const built-in trait Date: Fri, 5 Jan 2024 21:05:35 -0800 Message-ID: <20240106050754.3054782-2-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Q3-D01u15F7cKEnNjo7yafQ_GbmuGPEe X-Proofpoint-GUID: Q3-D01u15F7cKEnNjo7yafQ_GbmuGPEe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=704 adultscore=0 impostorscore=0 phishscore=0 clxscore=1034 spamscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112020272549532 X-GMAIL-MSGID: 1787316681410803150 This patch implements built-in trait for std::is_const. gcc/cp/ChangeLog: * cp-trait.def: Define __is_const. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_CONST. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_const. * g++.dg/ext/is_const.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 +++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 +++ gcc/testsuite/g++.dg/ext/is_const.C | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_const.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index fef68cf7ab2..669803b586c 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3734,6 +3734,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_CLASS: inform (loc, " %qT is not a class", t1); break; + case CPTK_IS_CONST: + inform (loc, " %qT is not a const type", t1); + break; case CPTK_IS_CONSTRUCTIBLE: if (!t2) inform (loc, " %qT is not default constructible", t1); diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 394f006f20f..36faed9c0b3 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -64,6 +64,7 @@ DEFTRAIT_EXPR (IS_ASSIGNABLE, "__is_assignable", 2) DEFTRAIT_EXPR (IS_BASE_OF, "__is_base_of", 2) DEFTRAIT_EXPR (IS_BOUNDED_ARRAY, "__is_bounded_array", 1) DEFTRAIT_EXPR (IS_CLASS, "__is_class", 1) +DEFTRAIT_EXPR (IS_CONST, "__is_const", 1) DEFTRAIT_EXPR (IS_CONSTRUCTIBLE, "__is_constructible", -1) DEFTRAIT_EXPR (IS_CONVERTIBLE, "__is_convertible", 2) DEFTRAIT_EXPR (IS_EMPTY, "__is_empty", 1) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 082fe2db4f2..1a6f08c37ec 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12415,6 +12415,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CLASS: return NON_UNION_CLASS_TYPE_P (type1); + case CPTK_IS_CONST: + return CP_TYPE_CONST_P (type1); + case CPTK_IS_CONSTRUCTIBLE: return is_xible (INIT_EXPR, type1, type2); @@ -12657,6 +12660,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_ARRAY: case CPTK_IS_BOUNDED_ARRAY: case CPTK_IS_CLASS: + case CPTK_IS_CONST: case CPTK_IS_ENUM: case CPTK_IS_FUNCTION: case CPTK_IS_MEMBER_FUNCTION_POINTER: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index 02b4b4d745d..e3640faeb96 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -71,6 +71,9 @@ #if !__has_builtin (__is_class) # error "__has_builtin (__is_class) failed" #endif +#if !__has_builtin (__is_const) +# error "__has_builtin (__is_const) failed" +#endif #if !__has_builtin (__is_constructible) # error "__has_builtin (__is_constructible) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_const.C b/gcc/testsuite/g++.dg/ext/is_const.C new file mode 100644 index 00000000000..8a0e8df72a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_const.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +class ClassType { }; +using cClassType = const ClassType; +using vClassType = volatile ClassType; +using cvClassType = const volatile ClassType; + +// Positive tests. +SA(__is_const(const int)); +SA(__is_const(const volatile int)); +SA(__is_const(cClassType)); +SA(__is_const(cvClassType)); + +// Negative tests. +SA(!__is_const(int)); +SA(!__is_const(volatile int)); +SA(!__is_const(ClassType)); +SA(!__is_const(vClassType)); From patchwork Sat Jan 6 05:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6618905dyb; Fri, 5 Jan 2024 21:10:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVe1QATrmtPGz+IQBUo+Rzh3Ox7m8mJpCtNX8DBnvH3yCTCrcaan7IQa/KGSV5rhDhBUYo X-Received: by 2002:a05:622a:1647:b0:429:7ce7:99a3 with SMTP id y7-20020a05622a164700b004297ce799a3mr582371qtj.5.1704517818165; Fri, 05 Jan 2024 21:10:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517818; cv=pass; d=google.com; s=arc-20160816; b=C738YRTclvyrng89mGwv+/4c1ojc8LKye7GHPbX2Cie4dSJdGnrNWJQnMifAq9XdjN klR6vZOBqCtjyp+5sk7fuab/Q7X8EYaVJKJN/hImC1cYWACtQiZbSKH06OrdS7jw5La6 ws3x9uYk04rczBJdnRtn0tDsOo6k1rYsunF4AAdvvHsYsJ9nFBE5f0SW1eWzVAs7Tc9O rKCQaq0kQA2bPBiG2sUBNKE91uPFpVZpnVbjcTO22ACSOyWCcthh9lqGkXpDexpfpMZd 639wL5kj27zmfXgsdWUT2QTOdMZdvTWG/wKGxCgGspG9PR8gDHlSN8A693gv0jyu0P1O 8Ryw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=3sarJGk6J16MGc/EQLNG5yN2sxg0pLj9UooV400ZnBU=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=0dGU9jbHoqWolhn5ItJhmgIYfqh3SjM6ybd5IZd1H5+ZKb8v2g0F93jwdPqwXxMV/4 bjk5ezTNL2yCAuXLUc38uLKH5Yy2DolcBljHtwEzfZ9OEVNvB2E4rGdts+B/+YzNuIml zteRgCdqBIkTqmWgG86FlYg66fvRAUNWZu9yUzcwQibLd7pbZMLpkVFtwin9s7BfqJSY 3CZUu+roEN20ETTJYMQjb3PuaSQNb5TQy07O6387mraiwN7uClEm2gM016sLf6oJvrMj lrDQEO/njXBaoDjPceECrFfcVshAb2ssudNwR9HMcZg3wtXr6ii6FqkiBcGkb0iqlPxF 20iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dBIAXGoB; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ay23-20020a05622a229700b004297b77f9f1si2071932qtb.93.2024.01.05.21.10.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:10:18 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dBIAXGoB; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AC6A3864C69 for ; Sat, 6 Jan 2024 05:10:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AC6A3864C69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517813; bh=3sarJGk6J16MGc/EQLNG5yN2sxg0pLj9UooV400ZnBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dBIAXGoBH+qq94fegFF+QC8kBGlOI2G+Tf46BPpUuw8QU3QMaev9kysXrFab6d/oJ ffvu5Zch2+8myUESHNdIB9g0auw6iZ0pKyQtpBCqE8V822bKTlGeOLffS6LCw+CO5D 2OrFrh4zKjO8uqqMgSsQw0ZX7kjjylWr4q1EO6NU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00641c01.pphosted.com (mx0a-00641c01.pphosted.com [205.220.165.146]) by sourceware.org (Postfix) with ESMTPS id CAE153858419; Sat, 6 Jan 2024 05:08:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAE153858419 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CAE153858419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.165.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517729; cv=none; b=dn5FnLaSPETGJFT8M0otM4VwctigHCOxI6lTZDUMNkJOY5GDd9z2KcH5eizRz5sqwjbeWFuiagndcQW6E7RlyjZU0QcyjAMlPyYLJJRULBK+WTztzJy1NbS2VNS2x6IUWhnLP8JP5iezVMwxIw6/C6Yn9Iv0WJFnPu/e22FY2fk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517729; c=relaxed/simple; bh=sfklRqWZpv77AW/FNprnSHewugKtcGAhriMlZEkxERg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=sF5ku5dxUySMIiR6SeV/patinS0IlizpvArcVZ9y3coW6XeNanH7Qej4K/aG0LimwJZ93qYjpLC76WxPlI4x/PnpZRrPoaykkD2LbL8Pev38XrxWUoMVxgTqo9a1R23FujSTTj+KXBnBdaEEJc2pxzDI4PV0+O40neIASuF55Q4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247475.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4064u04W012140; Sat, 6 Jan 2024 05:08:46 GMT Received: from mxout24.cac.washington.edu (mxout24.cac.washington.edu [140.142.234.158]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vey2q88bk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:08:46 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout24.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658gTt025199 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580H7000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 2/8] libstdc++: Optimize std::is_const compilation performance Date: Fri, 5 Jan 2024 21:05:36 -0800 Message-ID: <20240106050754.3054782-3-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: 9zxXgn-QcZywOWnFxvRBpjNOlswkvu3J X-Proofpoint-ORIG-GUID: 9zxXgn-QcZywOWnFxvRBpjNOlswkvu3J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 clxscore=1034 mlxlogscore=623 lowpriorityscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112060520651610 X-GMAIL-MSGID: 1787316475838772061 This patch optimizes the compilation performance of std::is_const by dispatching to the new __is_const built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_const): Use __is_const built-in trait. (is_const_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3b1b419bbbb..e64ed1de891 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -835,6 +835,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Type properties. /// is_const +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) + template + struct is_const + : public __bool_constant<__is_const(_Tp)> + { }; +#else template struct is_const : public false_type { }; @@ -842,6 +848,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_const<_Tp const> : public true_type { }; +#endif /// is_volatile template @@ -3315,10 +3322,15 @@ template inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) +template + inline constexpr bool is_const_v = __is_const(_Tp); +#else template inline constexpr bool is_const_v = false; template inline constexpr bool is_const_v = true; +#endif #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) template From patchwork Sat Jan 6 05:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6618913dyb; Fri, 5 Jan 2024 21:10:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcwu28bOr54IRutfuU15ExmI+cpbAK2w68DTolWEBnu91K5HOrF5UNhqEEJmv515PWs7cM X-Received: by 2002:ae9:f20d:0:b0:781:5844:aa45 with SMTP id m13-20020ae9f20d000000b007815844aa45mr448192qkg.108.1704517819704; Fri, 05 Jan 2024 21:10:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517819; cv=pass; d=google.com; s=arc-20160816; b=c3EtkyoZwMlhjn7GQnyOzbqfKVG4ZHUEbnCHbwxzpEU2cFEbfYxKEj5dRB/BoPzwg8 2o8B+cHD1EXj+CGZJY9fAT5F0zRYhzDEPYRSaRHUv/hafhkJcJElGYaMO4tM+Rihfqet /irDD/onYfEcwT+gbTW1IwJ+n6pK9e8DYB7VRGpept5wNeJyLiHC6vOjLsDT0ymYdakp 9KY0RPKAVr5awMtOpiiji394rbjT4LFk0Fka7lNa0Mxf6hEqaXZO3K1XSq8b+Cz4M6Q+ Ian5EkGaUjSs8gBhzGmIiA27Jvf7ccqznM6lcntbtrjJu+M6gapKg9586x8N46w+w3id ZoEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=FH3Kj0DfeMS85/G4GoPGCx0cBYgxD7nJZUKMoZqSrnU=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=nVw7LoXjht5qkzrdW9/eZaJO0pJcSLeytWZ5ounee+axuUKs5nXxO+9ckAszAFPr2m Vq5+ktGVvaeIKrEKXsk5M1jTG8BrE5X4zR3OtmzvdbY9KT7H8pazQvA1r2HRLN2qSU21 JF/rK65P8GJTiMetcFs0Rwr6S0UEpTEfjvQhyW8RKXS+zZd6QLjFIMSrAVEzySMRaxOE ozoQHtXVrSyvOzl0LVizHOBx/aEMNBmgg/Yrs/0u3vMNTYWDKoUnR3d/km9WwFXnLu0K eFVBdb0wCdAiWQSpx0u21xw/FwoWwKfcfvK34QSH/fykDGyphi8EQ2zmy+gPkh5qCYaP E/mA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eSXfGMqn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dw6-20020a05620a600600b007811c39c8cbsi3458378qkb.713.2024.01.05.21.10.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:10:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eSXfGMqn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB2E9384CB97 for ; Sat, 6 Jan 2024 05:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB2E9384CB97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517815; bh=FH3Kj0DfeMS85/G4GoPGCx0cBYgxD7nJZUKMoZqSrnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eSXfGMqnbxa5voKcfaNJdxgc2Mkh6HDbB0f2jrxSezlAZdF+MKOb1RmJJcc/CvyzR b5ixgTwllW/ZFDTdcZpt1UUx5E+spXliVbZcGj+isHdXNVzLG8zALb5XgWCjvTlnuT nJFXLBAUj1/5hsfJ4epMaHVc0DhsiLJIrwxFb38Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 5E5B938618FD; Sat, 6 Jan 2024 05:08:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E5B938618FD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5E5B938618FD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517734; cv=none; b=NgB2JXknIV12WdY0ouC4XEKtF2sZuGEoCHlZJmRKJrgwIVuyNkTHCPN6l+DEswHZPPerasQbJqua9Cx6Nmceg+MM3AKxLHvhLBYs0Ve6s91v9OkhhZf/aBFVh3P9MVL1BvMbl6X5aHYZ33eYO6unUPKmFxPOrtmBFGoYKb8RZ5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517734; c=relaxed/simple; bh=nq/yW0XOrFtp9IdzmbiKPXYkvTWl158AY/WkYa4gO8w=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=E7jepiDjgnomHo795Xoa0MosZiE9iXc4LoNBtbaY0IYRW+84kb6KJfQDV7tq37RXAj5cyIrR5iTtQ4rD1b0XcYZDX6Ex1IUh03+K0a9mkQfjbn8PgxTBiCE5G0I7HfeXqcKDDCwcXWdlm27G1TW1zH1Dcs6rMD3/lxvbNu8+rTM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40658pgL015964; Sat, 6 Jan 2024 05:08:51 GMT Received: from mxout23.cac.washington.edu (mxout23.cac.washington.edu [140.142.32.140]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vevjpgw84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:08:50 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout23.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658g3P005189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580H8000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 3/8] c++: Implement __is_volatile built-in trait Date: Fri, 5 Jan 2024 21:05:37 -0800 Message-ID: <20240106050754.3054782-4-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: 7Jlpb-71cSc7USEd1Vp3GE9dEzILDRfF X-Proofpoint-ORIG-GUID: 7Jlpb-71cSc7USEd1Vp3GE9dEzILDRfF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1034 bulkscore=0 mlxlogscore=675 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112119857678566 X-GMAIL-MSGID: 1787316477251222976 This patch implements built-in trait for std::is_volatile. gcc/cp/ChangeLog: * cp-trait.def: Define __is_volatile. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_VOLATILE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_volatile. * g++.dg/ext/is_volatile.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 +++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 +++ gcc/testsuite/g++.dg/ext/is_volatile.C | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_volatile.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 669803b586c..6f13546b9b2 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3828,6 +3828,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_UNION: inform (loc, " %qT is not a union", t1); break; + case CPTK_IS_VOLATILE: + inform (loc, " %qT is not a volatile type", t1); + break; case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: inform (loc, " %qT is not a reference that binds to a temporary " "object of type %qT (direct-initialization)", t1, t2); diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 36faed9c0b3..e9347453829 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -92,6 +92,7 @@ DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2) DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1) DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) +DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2) DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 1a6f08c37ec..0f304cdc642 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12501,6 +12501,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_UNION: return type_code1 == UNION_TYPE; + case CPTK_IS_VOLATILE: + return CP_TYPE_VOLATILE_P (type1); + case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: return ref_xes_from_temporary (type1, type2, /*direct_init=*/true); @@ -12671,6 +12674,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: case CPTK_IS_UNION: + case CPTK_IS_VOLATILE: break; case CPTK_IS_LAYOUT_COMPATIBLE: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index e3640faeb96..b2e2f2f694d 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -158,6 +158,9 @@ #if !__has_builtin (__is_union) # error "__has_builtin (__is_union) failed" #endif +#if !__has_builtin (__is_volatile) +# error "__has_builtin (__is_volatile) failed" +#endif #if !__has_builtin (__reference_constructs_from_temporary) # error "__has_builtin (__reference_constructs_from_temporary) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_volatile.C b/gcc/testsuite/g++.dg/ext/is_volatile.C new file mode 100644 index 00000000000..80a1cfc880d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_volatile.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +class ClassType { }; +using cClassType = const ClassType; +using vClassType = volatile ClassType; +using cvClassType = const volatile ClassType; + +// Positive tests. +SA(__is_volatile(volatile int)); +SA(__is_volatile(const volatile int)); +SA(__is_volatile(vClassType)); +SA(__is_volatile(cvClassType)); + +// Negative tests. +SA(!__is_volatile(int)); +SA(!__is_volatile(const int)); +SA(!__is_volatile(ClassType)); +SA(!__is_volatile(cClassType)); From patchwork Sat Jan 6 05:05:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6618938dyb; Fri, 5 Jan 2024 21:10:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVoqzeXfX+GOJss3iNHXcfjWtYAP7FMDVxwGHmjIBww/OTX0pdCDRIr2S0zihjXwxQT/6L X-Received: by 2002:a05:620a:26a4:b0:783:690:d1c1 with SMTP id c36-20020a05620a26a400b007830690d1c1mr507901qkp.37.1704517826762; Fri, 05 Jan 2024 21:10:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517826; cv=pass; d=google.com; s=arc-20160816; b=gxKLpH6kWOq68M/Q3pD5S2hyIm8af+D099KvAZZewnwMhClL0DIYWQq52bt+5WCqw0 cRG7RFB1ufgYtP0i3toh96QzCEVeqgD9A0Vg0s1MmfLbP8uCfhQALYq6xgx7A6C/4Cv+ 9J15mZeYIkAEIVTsukAohoKQWJVnqil5s0msz5o14UtlOkL9flqr7bVWdeUqkVbTK5iy A8inU6Ul4VJR5XBdFSEqxgFfPwADDxAdYJk1JXe7ObhmUyHBsp8hIbKOJT4BTN8zd0gY oDj//e04qXgUeRcM5TsNzQ/pTTMLNTdCsHv6MTHycLZSp7Q39VtNt77ToYCTmwpHTyHm eJNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=+NNc4m5RWHKjYBPFqVbAGVlldmy/asZPt2qYkJhn0Hg=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=s0FIwgf+3W1Bs79aVFXVU+9+3d5HK0jrZuVVz46Iz76cgpIVKuUYiWhGyOX5yUweHK W/slfP79wAhOr0tKZuOJrUb9uXCcMbkhYd7Gzs/eY9SPQMyqqZYAGvRpJMfpNRPVOmvQ vnxbpwxyF+Pl5G8qR+xwbmsQ6rVsul3B70T4HnzXCMKKfc8czHLRpn2w5QzPQ4rKfi/K otnohBb42WVhiwqZwSjjOOZeUPbmC1MKEevtrItgpt/co1MaPtCzQLl7MrxjQM4KJmx+ o4zbkkr3FMQvzgF1aSikGmegHlTkxM1j8TPEK6ESEOPaJVLui5yUXBZhc9StxHfy9XLZ +pGA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=curNFb7D; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u18-20020a05620a0c5200b00781575a8695si3372179qki.667.2024.01.05.21.10.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:10:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=curNFb7D; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5057D3864879 for ; Sat, 6 Jan 2024 05:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5057D3864879 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517826; bh=+NNc4m5RWHKjYBPFqVbAGVlldmy/asZPt2qYkJhn0Hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=curNFb7DhuSJRepXZJqJ1jzyrrWNHsQn7+f1fdV3sZR4iuTU3p9RBfmQsq3T/W2Z4 3t8HfHZ5nuP9DbKpjsRlcPiCAUiRQqLSIEl3+t2KAEqqX4vQWobEl9z7wZLaNbKZMW yT6WUuCeSmZqgQ1UfIFWr2heRP95dhYkb1+6JGh4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 9A63B384DEF1; Sat, 6 Jan 2024 05:09:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A63B384DEF1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9A63B384DEF1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517748; cv=none; b=YZXsCIqY9/FBvlCCu9z3m5kgD2ZireFsiCVRuwMrqHICT2UNGuTzRL7g5mXApZutF5RIMd6yISVVLRY3HMJUsB7gNTj2Nr0VpnFNpE7FZh2080Xwo/7Jw18gyYactCbAXOvzq9kjS4CanlZ7VNBk7nV6mHJVomJzccFyTet9izU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517748; c=relaxed/simple; bh=+Pkypz/2SPpM3MJ9QZA8sGOYodUGZC8P+T/zM3ZgGq4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=t8qk6To7dmtN7k2Fo6f5Lz1/QfdajD26EYzGGKLsBGKLbN7f4EEbnAjk4ZL/Z2e1oBP5lhdVe+Yy2wsNEyePmYc0jKtYTCu9D8guDftFK1jhdYnoXic67AMel9IU6BZNe+mXwev0TUcoMueEjG4IBz00kwHubjVxtknDESFt888= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40651eVC005207; Sat, 6 Jan 2024 05:09:05 GMT Received: from mxout21.s.uw.edu (mxout21.s.uw.edu [140.142.32.139]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vevjpgw8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:09:05 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout21.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658gYM014358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580H9000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 4/8] libstdc++: Optimize std::is_volatile compilation performance Date: Fri, 5 Jan 2024 21:05:38 -0800 Message-ID: <20240106050754.3054782-5-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: ndApwCT9jtj-RC6mRiMKM5Fg6juLH0lo X-Proofpoint-ORIG-GUID: ndApwCT9jtj-RC6mRiMKM5Fg6juLH0lo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1034 bulkscore=0 mlxlogscore=703 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112126491765165 X-GMAIL-MSGID: 1787316484900414496 This patch optimizes the compilation performance of std::is_volatile by dispatching to the new __is_volatile built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_volatile): Use __is_volatile built-in trait. (is_volatile_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index e64ed1de891..2bfc31b141d 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -851,6 +851,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// is_volatile +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) + template + struct is_volatile + : public __bool_constant<__is_volatile(_Tp)> + { }; +#else template struct is_volatile : public false_type { }; @@ -858,6 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_volatile<_Tp volatile> : public true_type { }; +#endif /// is_trivial template @@ -3344,10 +3351,15 @@ template inline constexpr bool is_function_v<_Tp&&> = false; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) +template + inline constexpr bool is_volatile_v = __is_volatile(_Tp); +#else template inline constexpr bool is_volatile_v = false; template inline constexpr bool is_volatile_v = true; +#endif template inline constexpr bool is_trivial_v = __is_trivial(_Tp); From patchwork Sat Jan 6 05:05:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185586 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6619286dyb; Fri, 5 Jan 2024 21:11:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEopWZZfAYB2xRJKZiv1Nut30bOOWTxD/ESbjTVyKkLZErrSM2BuktYlFxtxWwrzN3/UptX X-Received: by 2002:a05:620a:12fb:b0:781:5e61:fb88 with SMTP id f27-20020a05620a12fb00b007815e61fb88mr483627qkl.3.1704517906667; Fri, 05 Jan 2024 21:11:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517906; cv=pass; d=google.com; s=arc-20160816; b=qO5PY+5TTwwwaIJ/SdMX87YdrOWXQn7j04qp7O2jVIAYepEBBaeWYUwWK/8NU61dnH 15jyWHzGAfOqd/lancU0zIGfUpKLrX3w4lBTvCi0bC6l+u+9hoTfNt+kQqfm+oR7tsT8 tCxCidvIAF36fMrLr+1IUxAvvShONLHSZDa2RwF2NZIeiwI4pIso5NeNku+86C3smA/H l6YbyCNsECgnGz4hxXixSUBSFZvWdUEq5ikv5cP+S0Ui3EENF7BZuo96Ppc5z4kfWWAD RooC1+YOvtfCOE6g0XBfYM7NuOnlZI4F5saeMeVvHxk9op8ky6eoQjeV0/aOueHUcF5Z 8UFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=7AD/WLx2rB0idblU9CokzxJ4k39jyANRIuLGvH2QsK4=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=x4aPFzuczSzOPg6fjj3LbcbdfGd2hIr3P6f/lG7QIIro8AGK6urrxSoGgPPy5x9rMu jOXMJ/d/SLu3WDj3jyhEdMBYLKM3OUgaX8PsZBlAlvzPdqNjIIMnjTkYjRKUeI1yfHGt Wbs82rCz9KulF7HHXuP5q0b1hnPA+Jt0dddLgcuovvxIOBK4vCW/7u4JKrcs6RtuVZy7 91j/uBBObc+R2Ah7dQsC40UfqgddHSmLJK9G59podM7qFACBHJ6VZdAJUvlaCsb1VCOx mHQ8NQofU+Bhlc3S0xHgVZkP2CNGv0SCnCdNm53fV8hQy3B7GP9ujSLWM+Xxj0jb220j 5kcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Lnk165+I; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g10-20020a05620a40ca00b00781cac19c05si3547319qko.612.2024.01.05.21.11.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:11:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Lnk165+I; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 519AF384CB8F for ; Sat, 6 Jan 2024 05:11:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 519AF384CB8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517906; bh=7AD/WLx2rB0idblU9CokzxJ4k39jyANRIuLGvH2QsK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Lnk165+Ivx9MP/UEWtvvBcom3I+/sNpdQWhtA+UYESGB0TBdeCg6FDSITbw5d1ZG/ VK0tXVZaA/RpbtK5xICmJ7LvD0mv5uOmAFs6wMM1ATn9lHnnmrMrTx3DKbhCazmXvw m7xOKtB8G4m6Hcuhz/rQLQE5AyvC4uxXRIsUTtdk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 7A8D1384F020; Sat, 6 Jan 2024 05:08:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A8D1384F020 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A8D1384F020 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517738; cv=none; b=mSw6sVptQpRwthyaQS2c4AYXZcicMX3SEORf+QIRntLFWDZ3lJPZwqdUYgwcEJA1lcmJaJKqAr5Td938nk3r9SmJeEPITwLCSVuNsFXIRtOyirQuL06Z+xwpTcoCM/55HURGRU6iRPAVYu5HCDwQql+dMyohosTUwOEbxvJ9SuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517738; c=relaxed/simple; bh=g04JkD8oS95FNF+8YCi5+rHYw1/3jdrnuQlz2ktvtiI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NJ8U2leCFd6djiFB04kvMlY/Iv5SX1tkH8IHhozz6VWa7vxxBEhtohlubdilGrSHhbXmJ9Jjjd+KLJfkbljNZBFzYg4+0Fr7C6F5bXDo1Kdn4DOnL+wEnyIGNu2KnTz1cr7WCumBKpQPyFpZGo86g161kzS5ljq2zxW5Izeb2aI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247476.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40657q1e008138; Sat, 6 Jan 2024 05:08:56 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vexq30b0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:08:55 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658gni007595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580HA000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 5/8] c++: Implement __is_pointer built-in trait Date: Fri, 5 Jan 2024 21:05:39 -0800 Message-ID: <20240106050754.3054782-6-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: OerAY82cTOVZTlLuGSYni9zP4NVdP6kk X-Proofpoint-GUID: OerAY82cTOVZTlLuGSYni9zP4NVdP6kk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1034 impostorscore=0 bulkscore=0 spamscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 mlxlogscore=722 adultscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112185994066034 X-GMAIL-MSGID: 1787316568465666456 This patch implements built-in trait for std::is_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer. * g++.dg/ext/is_pointer.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 ++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 ++++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 6f13546b9b2..3d7c0509f6b 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3795,6 +3795,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_POD: inform (loc, " %qT is not a POD type", t1); break; + case CPTK_IS_POINTER: + inform (loc, " %qT is not a pointer", t1); + break; case CPTK_IS_POLYMORPHIC: inform (loc, " %qT is not a polymorphic type", t1); break; diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index e9347453829..18e2d0f3480 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -82,6 +82,7 @@ DEFTRAIT_EXPR (IS_NOTHROW_CONVERTIBLE, "__is_nothrow_convertible", 2) DEFTRAIT_EXPR (IS_OBJECT, "__is_object", 1) DEFTRAIT_EXPR (IS_POINTER_INTERCONVERTIBLE_BASE_OF, "__is_pointer_interconvertible_base_of", 2) DEFTRAIT_EXPR (IS_POD, "__is_pod", 1) +DEFTRAIT_EXPR (IS_POINTER, "__is_pointer", 1) DEFTRAIT_EXPR (IS_POLYMORPHIC, "__is_polymorphic", 1) DEFTRAIT_EXPR (IS_REFERENCE, "__is_reference", 1) DEFTRAIT_EXPR (IS_SAME, "__is_same", 2) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 0f304cdc642..4b75ff744d4 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12471,6 +12471,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_POD: return pod_type_p (type1); + case CPTK_IS_POINTER: + return TYPE_PTR_P (type1); + case CPTK_IS_POLYMORPHIC: return CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1); @@ -12670,6 +12673,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_MEMBER_OBJECT_POINTER: case CPTK_IS_MEMBER_POINTER: case CPTK_IS_OBJECT: + case CPTK_IS_POINTER: case CPTK_IS_REFERENCE: case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index b2e2f2f694d..96b7a89e4f1 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -125,6 +125,9 @@ #if !__has_builtin (__is_pod) # error "__has_builtin (__is_pod) failed" #endif +#if !__has_builtin (__is_pointer) +# error "__has_builtin (__is_pointer) failed" +#endif #if !__has_builtin (__is_polymorphic) # error "__has_builtin (__is_polymorphic) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_pointer.C b/gcc/testsuite/g++.dg/ext/is_pointer.C new file mode 100644 index 00000000000..d6e39565950 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_pointer.C @@ -0,0 +1,51 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +SA(!__is_pointer(int)); +SA(__is_pointer(int*)); +SA(__is_pointer(int**)); + +SA(__is_pointer(const int*)); +SA(__is_pointer(const int**)); +SA(__is_pointer(int* const)); +SA(__is_pointer(int** const)); +SA(__is_pointer(int* const* const)); + +SA(__is_pointer(volatile int*)); +SA(__is_pointer(volatile int**)); +SA(__is_pointer(int* volatile)); +SA(__is_pointer(int** volatile)); +SA(__is_pointer(int* volatile* volatile)); + +SA(__is_pointer(const volatile int*)); +SA(__is_pointer(const volatile int**)); +SA(__is_pointer(const int* volatile)); +SA(__is_pointer(volatile int* const)); +SA(__is_pointer(int* const volatile)); +SA(__is_pointer(const int** volatile)); +SA(__is_pointer(volatile int** const)); +SA(__is_pointer(int** const volatile)); +SA(__is_pointer(int* const* const volatile)); +SA(__is_pointer(int* volatile* const volatile)); +SA(__is_pointer(int* const volatile* const volatile)); + +SA(!__is_pointer(int&)); +SA(!__is_pointer(const int&)); +SA(!__is_pointer(volatile int&)); +SA(!__is_pointer(const volatile int&)); + +SA(!__is_pointer(int&&)); +SA(!__is_pointer(const int&&)); +SA(!__is_pointer(volatile int&&)); +SA(!__is_pointer(const volatile int&&)); + +SA(!__is_pointer(int[3])); +SA(!__is_pointer(const int[3])); +SA(!__is_pointer(volatile int[3])); +SA(!__is_pointer(const volatile int[3])); + +SA(!__is_pointer(int(int))); +SA(__is_pointer(int(*const)(int))); +SA(__is_pointer(int(*volatile)(int))); +SA(__is_pointer(int(*const volatile)(int))); From patchwork Sat Jan 6 05:05:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6619552dyb; Fri, 5 Jan 2024 21:12:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJDO0rIBj5gvM+BnESj5ZDu3YS68VWtiudHGRUrrpE/iLh3eUwJYLz35qrcIkq6C/bNByq X-Received: by 2002:a05:622a:11d3:b0:428:3519:ad1f with SMTP id n19-20020a05622a11d300b004283519ad1fmr620982qtk.126.1704517967491; Fri, 05 Jan 2024 21:12:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517967; cv=pass; d=google.com; s=arc-20160816; b=02AoRaHyh6qHtrt6GqlKYDZM3uTMEokwRXnV6CJ1av5dpOBp6hb/PjTrG7bEV/9zK2 Pp62xlhCDCCu7kQmsJAl8fol7R/rHbPrjggor0BWTHw/eXutz42aLOuon1SMlsrEKgY3 JgTXl7Nwk5JJ0x9fM36+X9KULi9FgkqGA6alhQ0KG1ObebJL4AsoJmg06bsQhcm5cs+X Pz/O8E7RCq3syWDuI0xz4/rZLtxfCKRhxDNYOs3yoiU4Bi+uOnE4qs89oWIBL5NVGuKS jmafcmCRraSy5m22CbF9slwH3ePldlRif8/n1gTwebn8210MLanuI9c0+ja7pwh4isQo VUOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=PNV0BsJtXxSmG79ukl/ALjFcsCSjh9GfY3uj0tGDPag=; fh=2MU6VW487KDeEvI5/nTaFmO/pzM6rabW6FcP4yf4iBE=; b=d6LhUnugUtnHPgdN22sdBOgN81e5ZW78R5VH5ZyKV6GJlhCQBAeV6ukKBffksJKn5I b3zL5iHK4aipT5Snsauxee6xJayKp4C4XHu/iVQ2iGj2/pqsz7WkNGNsgGLxASYzYDOS yc5EZ3hiccHnurSQjVPxqNsXsC56tpUGGQsVLhlAKBal3QvdLcRdrGlefdkLrIDGgltu FcLti6HHOKkBarPFg3q+8lEfhKmV+norpI+q+ys1ip3XxI5HGY/XLNWbZwL7Q5HJxAjY RfqVVv0KLdpH+5Yiy5mSZkNDqeSus00gCKpfyfyfXF//ozShfjymB179NK9JPMULcJoh jC/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bfvCayek; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h20-20020ac87d54000000b004283cdca114si3369661qtb.689.2024.01.05.21.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:12:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bfvCayek; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AE843860778 for ; Sat, 6 Jan 2024 05:12:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AE843860778 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517967; bh=PNV0BsJtXxSmG79ukl/ALjFcsCSjh9GfY3uj0tGDPag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bfvCayektRSQ4dYfkr2938zdcDtIGa01IKy2XU2nW7ZntqvqN2pKzQG0biwOBbmn+ rARFqNodkRrX9lcQL9rsJh0LxR0Yl5a0lChiZSD/0bRb+I6+Bd8YmulB0ZncM69F/Q UeL3dWUyy0GiJZ8zKQcnOnQngnLHvRx7uveWeIaE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 5C1B43858C60; Sat, 6 Jan 2024 05:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C1B43858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C1B43858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517746; cv=none; b=tJxX7CaTxDpwYIjWYtwKyquoZjxXCjp333PC7wZ5Ci4LkL29TJQkvGerpWEEr2gJAwGCHQOj0osYRJ8Ted96kdJJO2/fc/BhWmTLY4OaAUsxjt1rE/d48T/7b+HUFVFXhFfpNV3ZgrPGVxYCYVKWWI+Fw9VB4El5ioNhdjARaz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517746; c=relaxed/simple; bh=2Moc8xw2ycREZryZ6hTo8/VUzcf5kbgwiyMoiMxBzKo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xe7E1d2VLKKTwjTotojmglvEDwNsqJsduzSydhFPvaqUajnUt7l5Ll6CwqTZMEZ+VrgG5UZ1sduJ38FOT0cGLPJFiC8icY5pW3Pizldo7mjLjxEVLr2p3uN5SG9qCvttWr1Tjh9/MPGHjxgBPgrCtG1PPlYDi5sKYx6AdIhv93o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40653Nv2007801; Sat, 6 Jan 2024 05:09:03 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vevjpgw8g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:09:02 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout26.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658g3U027442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:43 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580HB000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui , Jonathan Wakely Subject: [PATCH v3 6/8] libstdc++: Optimize std::is_pointer compilation performance Date: Fri, 5 Jan 2024 21:05:40 -0800 Message-ID: <20240106050754.3054782-7-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: wYmkFd8yi2aaWvbZbS_d5otPImrr8qtb X-Proofpoint-ORIG-GUID: wYmkFd8yi2aaWvbZbS_d5otPImrr8qtb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1034 bulkscore=0 mlxlogscore=360 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112186161256731 X-GMAIL-MSGID: 1787316632504133113 This patch optimizes the compilation performance of std::is_pointer by dispatching to the new __is_pointer built-in trait. libstdc++-v3/ChangeLog: * include/bits/cpp_type_traits.h (__is_pointer): Use __is_pointer built-in trait. Optimize its implementation. * include/std/type_traits (is_pointer): Likewise. (is_pointer_v): Likewise. Co-authored-by: Jonathan Wakely Signed-off-by: Ken Matsui --- libstdc++-v3/include/bits/cpp_type_traits.h | 31 ++++++++++++++- libstdc++-v3/include/std/type_traits | 44 +++++++++++++++++---- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 59f1a1875eb..210a9ea00da 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -363,6 +363,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // // Pointer types // +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct __is_pointer : __truth_type<_IsPtr> + { + enum { __value = _IsPtr }; + }; +#else template struct __is_pointer { @@ -377,6 +384,28 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) typedef __true_type __type; }; + template + struct __is_pointer<_Tp* const> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template + struct __is_pointer<_Tp* volatile> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template + struct __is_pointer<_Tp* const volatile> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + // // An arithmetic type is an integer type or a floating point type // @@ -387,7 +416,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // // A scalar type is an arithmetic type or a pointer type - // + // template struct __is_scalar : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 2bfc31b141d..018bf20ba1d 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -542,19 +542,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public true_type { }; #endif - template - struct __is_pointer_helper + /// is_pointer +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct is_pointer + : public __bool_constant<__is_pointer(_Tp)> + { }; +#else + template + struct is_pointer : public false_type { }; template - struct __is_pointer_helper<_Tp*> + struct is_pointer<_Tp*> : public true_type { }; - /// is_pointer template - struct is_pointer - : public __is_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + struct is_pointer<_Tp* const> + : public true_type { }; + + template + struct is_pointer<_Tp* volatile> + : public true_type { }; + + template + struct is_pointer<_Tp* const volatile> + : public true_type { }; +#endif /// is_lvalue_reference template @@ -3252,8 +3266,22 @@ template inline constexpr bool is_array_v<_Tp[_Num]> = true; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) +template + inline constexpr bool is_pointer_v = __is_pointer(_Tp); +#else template - inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; + inline constexpr bool is_pointer_v = false; +template + inline constexpr bool is_pointer_v<_Tp*> = true; +template + inline constexpr bool is_pointer_v<_Tp* const> = true; +template + inline constexpr bool is_pointer_v<_Tp* volatile> = true; +template + inline constexpr bool is_pointer_v<_Tp* const volatile> = true; +#endif + template inline constexpr bool is_lvalue_reference_v = false; template From patchwork Sat Jan 6 05:05:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6619171dyb; Fri, 5 Jan 2024 21:11:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEk4riOc1M9D+/2+yZqIu6nd4EaBUfwu9bmR6VqZVNUfhpUBumLGUHcOS9rhSY6ozQoYcn0 X-Received: by 2002:a05:6214:529e:b0:67e:ceb4:4876 with SMTP id kj30-20020a056214529e00b0067eceb44876mr566585qvb.97.1704517879334; Fri, 05 Jan 2024 21:11:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517879; cv=pass; d=google.com; s=arc-20160816; b=MgOQq+5MG2DqQab73KHucZcvSGw3D2uSiBkegWBgCZAFFn7JaL+Fj5+jutKeyQzUNU s4KV32c5MxIH21Yjt5hSNJJecHjXQTzvjmphN7FB736YYhbhObRsqw8yPPpGj1svIbn0 MsqBL8azibrIVW0rFnJTbOdOIMZZW1pJZZrHfycUQ1d1gpYjdTXBep31JHs83J7Kwhbr X072H+LFFa99sPA2chqLWWaXYSV+gT2sshKUpL9Sndx61nBUn+F62FSjXUd3OsHmXd0Z j6kZBduzzE29WwxwVFJqmAba9ETM6kSUML+by44zjr24lASYWGdOaxYQgEN1SL1clbP4 sHAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=wvQXttHszYNJf+nlwBVKWRfAGzbaIgmySp2jCS1oGkw=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=YcpmbnVdMtuPRX3UxC0LlYdDmWb67OCGt+JlCFUCnoRGdK+l+Axf3fcWOpB27b5iRE fkl1k87Jjar07csY6BeR32+tUbdydDZk84WP6+6I8iIGgw6NpuED4+b89FvvppS5GY3f ey5W08pK6x6OF8sP1hBn9GOxOoT2am+RzvTQh6Lc5thJ9PO7VZph9wb/NaHFhUBdXJtn 5IIjn51K7gTQHLzIIzlQ6iUBcYYlkeyxMw/hKWeZ4iq+e6RhEaKo+579SyFbJ1Epu/l6 18cNSSH23TU5MuaopXNA1ys+ijGREcZvrDGMKZk8E92S3M5HlchUJhXOUJfLKCFPTZA5 gHsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WO26VyTP; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w9-20020a0cb549000000b0067f2956fe05si3314772qvd.504.2024.01.05.21.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:11:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WO26VyTP; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04F9C386486B for ; Sat, 6 Jan 2024 05:11:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04F9C386486B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517879; bh=wvQXttHszYNJf+nlwBVKWRfAGzbaIgmySp2jCS1oGkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WO26VyTPT4YPnskaEZkYoMm2xkhABedQ5JvlXqJRaWbSiQ0nYHnbOqQJ/jU/X6F3/ sParD9yiO49j40TGBHQtXxRjWas3l1TKRTVNzgJBfHOLDuqNaX2EED640RZBfzYZJY PYcHxLFf+2fmge+/NWMDFhEyQIydsn321IYdEVRY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 50F82385800A; Sat, 6 Jan 2024 05:09:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50F82385800A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 50F82385800A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517754; cv=none; b=ZgjiT7PeCQtHqarBEEnElagJtuzMopym6muE2uldO1TKVpcZUTdiDvJ/SL+0fD8BZj72vQEXPts8T9EgMpVn1ecN19TXq4RqRNCxjt/Ui3MG4/kRF/fqI3g7X9y559FXIhO3wJZ2tXuv/9kahrP8FjVR+LRYWgMn2EHaBirTFtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517754; c=relaxed/simple; bh=IsWsClNsYV6/sCHg8GQynpnases1QvGQ3hZa7qlVEp0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=DMgfbx2QuWi5EFpySCml9axTiVZGRQshCrW/4buolcS1ZPaM7ZHRgiFpQYF/QKx2l167j0GxXMlMdbu+G2Qf9vQ2EygUd5LpVAoweJFHQT7HY19rjoDjDQazeLa0Bb5CiP4VSjzVxz7uqydEOifidigDmCnB3Z0Ddqc9lB5FWho= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40653Nv3007801; Sat, 6 Jan 2024 05:09:12 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vevjpgw8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:09:11 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658gQu002806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:43 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580HC000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 7/8] c++: Implement __is_unbounded_array built-in trait Date: Fri, 5 Jan 2024 21:05:41 -0800 Message-ID: <20240106050754.3054782-8-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: tRd73pFGq1iao54W2SyF_7jStmNcQABd X-Proofpoint-ORIG-GUID: tRd73pFGq1iao54W2SyF_7jStmNcQABd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1034 bulkscore=0 mlxlogscore=602 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112219523462016 X-GMAIL-MSGID: 1787316540259693271 This patch implements built-in trait for std::is_unbounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_unbounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_UNBOUNDED_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_unbounded_array. * g++.dg/ext/is_unbounded_array.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 ++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ gcc/testsuite/g++.dg/ext/is_unbounded_array.C | 37 +++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_unbounded_array.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 3d7c0509f6b..9454739a76f 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3828,6 +3828,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_TRIVIALLY_COPYABLE: inform (loc, " %qT is not trivially copyable", t1); break; + case CPTK_IS_UNBOUNDED_ARRAY: + inform (loc, " %qT is not an unbounded array", t1); + break; case CPTK_IS_UNION: inform (loc, " %qT is not a union", t1); break; diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 18e2d0f3480..05514a51c21 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -92,6 +92,7 @@ DEFTRAIT_EXPR (IS_TRIVIAL, "__is_trivial", 1) DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2) DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1) DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) +DEFTRAIT_EXPR (IS_UNBOUNDED_ARRAY, "__is_unbounded_array", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 4b75ff744d4..a2ab945e50a 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12501,6 +12501,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_TRIVIALLY_COPYABLE: return trivially_copyable_p (type1); + case CPTK_IS_UNBOUNDED_ARRAY: + return array_of_unknown_bound_p (type1); + case CPTK_IS_UNION: return type_code1 == UNION_TYPE; @@ -12677,6 +12680,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_REFERENCE: case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: + case CPTK_IS_UNBOUNDED_ARRAY: case CPTK_IS_UNION: case CPTK_IS_VOLATILE: break; diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index 96b7a89e4f1..b1430e9bd8b 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -158,6 +158,9 @@ #if !__has_builtin (__is_trivially_copyable) # error "__has_builtin (__is_trivially_copyable) failed" #endif +#if !__has_builtin (__is_unbounded_array) +# error "__has_builtin (__is_unbounded_array) failed" +#endif #if !__has_builtin (__is_union) # error "__has_builtin (__is_union) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_unbounded_array.C b/gcc/testsuite/g++.dg/ext/is_unbounded_array.C new file mode 100644 index 00000000000..283a74e1a0a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_unbounded_array.C @@ -0,0 +1,37 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ + SA(TRAIT(TYPE) == EXPECT); \ + SA(TRAIT(const TYPE) == EXPECT); \ + SA(TRAIT(volatile TYPE) == EXPECT); \ + SA(TRAIT(const volatile TYPE) == EXPECT) + +class ClassType { }; +class IncompleteClass; +union IncompleteUnion; + +SA_TEST_CATEGORY(__is_unbounded_array, int[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int[], true); +SA_TEST_CATEGORY(__is_unbounded_array, int[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, int[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, float*[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, float*[], true); +SA_TEST_CATEGORY(__is_unbounded_array, float*[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, float*[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[], true); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, int(*)[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(*)[], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(&)[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(&)[], false); + +// Sanity check. +SA_TEST_CATEGORY(__is_unbounded_array, ClassType, false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass, false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteUnion, false); From patchwork Sat Jan 6 05:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 185589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6619952dyb; Fri, 5 Jan 2024 21:14:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0Ob5NVQInOOn5/6tW9UcACqZSibP7o6fiH+1UD7VA9nkRQd2euqe35Am0vQdofETgaSlf X-Received: by 2002:ad4:5d4c:0:b0:67f:2e67:c48e with SMTP id jk12-20020ad45d4c000000b0067f2e67c48emr549762qvb.76.1704518063954; Fri, 05 Jan 2024 21:14:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704518063; cv=pass; d=google.com; s=arc-20160816; b=bxbo4vDD8tPkp4MVj6BJSV61bQmGLAryQ1LAR0p1gs4qXPW57N0CatcZ0YWWzfXhc3 /2xHrs7GwVFoqoyiNYtu2yRqndt153os2JfSqIrHKDiWKHcyE/J3fF+e5WIaqloWZwDd wBhl0AZYBwevMuwQpYNjWAUKbAX20t1P1moOr1Eoe9YtHCcMDAtuvIV7oOBLo4TSNd5K oP3A8wW3ELpsPGOlQKxbNVu6DE2t9ctbvTznesrDbayNpTYjX0AmdmhI8VGmssaSxJSV V48MCvg6zgRzqjbFgjJ8IAwSHN5dyM2zuC7xPA042syRakAWiKF6XJMPpmOwkfQtIp0y x+sQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=9KRGtfSFabnE+iWbu1DB+GzpJKFwXle8oHgPI1fYCz4=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=suNV0BHq0XSBXhwsr0gTOYGWIl8nqvtqRqCZsaq+BEHCwoVbv096H87f8NbczvyUZb EN+O4DysPqI+hKH2SaKQ/GDtsOZCB5hindzLhp2D1abtrOxQwPlaVf1OLpu44VbpBCU1 SM1rNxLiQJbqHdY/anstfc1OpkzDgCnNYRx5uklXRiGqwB0guggFtebf3bCexBw48F3G ri2TziSDMZxYNEfw+Xh+tlE5QEt1DDggEDDSvDNOFkvNG9kzmHAC/kSg9AIbcxKPQvTy a7M5u/H+Pq57IklNvv9+zuR7qnEOZ6M+i79bNqqjUsDwp8QOavABpqUMDyWkq5MCqHdi Ut1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BQaQHwCm; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s14-20020a0cdc0e000000b0067f931f6bf8si3395166qvk.122.2024.01.05.21.14.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:14:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BQaQHwCm; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99BDB384DEFC for ; Sat, 6 Jan 2024 05:14:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99BDB384DEFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704518063; bh=9KRGtfSFabnE+iWbu1DB+GzpJKFwXle8oHgPI1fYCz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BQaQHwCmd3mxf/Q8vPcCjULS9dj94OdWfug1Us9J5IBnk8bCIbkFKc5QwTqJq6qSW nzlcYHgmZGrZU+KuKLxoRE40cOxUgB7NilsnVjiADb4LJ0PT0AbkHWKiyVrlxl0arc V+l8Q3CYUi/IZi/TmThzITS33lIt8UOFF8K39vR0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 2157F384DEF8; Sat, 6 Jan 2024 05:09:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2157F384DEF8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2157F384DEF8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517753; cv=none; b=WljfrtUk5XFJW1lTMA6+BU5cHSxwkAWv4kR0SrlVrAv2Dque5JlR6C2l2Igq1JAzwft2OgJOrW+X/K61hJS3gaJnTPvnsWQZUY5NMhAajq0HM1o2V3oRGV8Me1cY6X5dHM3iprW+puexi89lkIP6LvKpLKrtKvu1/ViIqA3TbaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517753; c=relaxed/simple; bh=ckpUwxgAjelsLoo9XTwBmw/qymCXnElSuZe2L6+exl0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=bjAzVuobH7p3WRrX7nav9va23JPmcU6DjInE29oA/SGg3eaZkkKIyTZSKPSxBs79iyyU7WFF5tgwJ7kdPgNEEXvYJsptv5s1G8g09OZ4+CGEmivgZS1JwFZvPCDTdbotCvmTtrWUq/xjrsMyQZtFE7yEcQj5X2DPUkxbBy22dCc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247479.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40659Bm7014141; Sat, 6 Jan 2024 05:09:11 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vexy188p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:09:11 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 40658hbO002807 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:43 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580HD000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:42 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v3 8/8] libstdc++: Optimize std::is_unbounded_array compilation performance Date: Fri, 5 Jan 2024 21:05:42 -0800 Message-ID: <20240106050754.3054782-9-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> <20240106050754.3054782-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: sRl9uE4WK58dI3gkpI1cd-rBxvXjNub7 X-Proofpoint-GUID: sRl9uE4WK58dI3gkpI1cd-rBxvXjNub7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 mlxlogscore=503 priorityscore=1501 suspectscore=0 mlxscore=0 clxscore=1034 bulkscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786112256931161952 X-GMAIL-MSGID: 1787316733558812689 This patch optimizes the compilation performance of std::is_unbounded_array by dispatching to the new __is_unbounded_array built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_unbounded_array_v): Use __is_unbounded_array built-in trait. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 018bf20ba1d..36344a014c3 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3675,11 +3675,16 @@ template /// True for a type that is an array of unknown bound. /// @ingroup variable_templates /// @since C++20 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unbounded_array) + template + inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp); +# else template inline constexpr bool is_unbounded_array_v = false; template inline constexpr bool is_unbounded_array_v<_Tp[]> = true; +# endif /// True for a type that is an array of known bound. /// @since C++20