From patchwork Tue Jan 9 13:16:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 186379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp102445dyi; Tue, 9 Jan 2024 05:22:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqDr0ycdADJqmxImYrP6eCn3lS5ZaUsIzCo/DQCPw9+YdSOQYYy2bU54/NKisIzwI+gArX X-Received: by 2002:a05:620a:3859:b0:783:3244:418f with SMTP id po25-20020a05620a385900b007833244418fmr196678qkn.83.1704806569909; Tue, 09 Jan 2024 05:22:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704806569; cv=pass; d=google.com; s=arc-20160816; b=ZSUje7UJoGcG+yPpeR7U/Djz4vG3p66qeq3uHn/Ykrj/a77w+sphj+PFr/HeCQ2lkC K9YyKlApe6jILgkjEF3W+MmOMkukH7apkoSOm9xLe+o9FUmYXQTRexYScFSVDpKz04KJ zbCp+38hU1yWJyDQblbpytsBswWg/hDyBQFe5kEA6bzpPl5ZUSWOnWJ2wpZI/1C7Pnzt FNrnHP3m0EvE9lY1OQnou42MrCOxVzGL3HquL8fkPFWrV3TQIXfP8b9ELJhD+mwVQqUF 4W5dszmTXwQtV9IqaM1ObzdT4y7cRz3jAYdcAf5JIvI5QB6JpbPTTYmXiMAWKQfLRBLi FTMA== 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:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=vXPgV06qKCv8n9hCtL7XaYVO8vlM2O9t1S+UdsCTXS0=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=C9D1UAdwlr4JCDAkFiol+Q308VEFj+JbMtu9gh9KI8yWZhP6D5QehJn6Fg97CEd2Qj s/8zjwqnyW1ZbNUZF6kef1r3j4Hp/T1+NWPp69U3pVK9vcM2b8VBUxIxDmL5V0lV56m/ ve+8HVrEIZR/Rm9/vD4GPlLOWkFEGImGfMacqBYR8BZWjvdY5f1f3GGt5wOl4W8O2Hlv 2toS+qsPj4/sEe3XnD43zxBrBXkZBJGmneDjnZewXhpC+4GmW6ijvFdCJBwyOyCSaJdK 6Hoe0/QuDS7GIqDWP09FgPJT2pGzrrNGWBxFWIC3BVvDE9VJUUSyYxIe2xvDDgc/U5RB WgRQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="fN1y/Ct5"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d20-20020a05620a241400b007817205d114si2140892qkn.662.2024.01.09.05.22.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:22:49 -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=@adacore.com header.s=google header.b="fN1y/Ct5"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9100B386187D for ; Tue, 9 Jan 2024 13:22:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 43F333861813 for ; Tue, 9 Jan 2024 13:16:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43F333861813 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43F333861813 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704806168; cv=none; b=U7N6VSoj4AiQ2RAIcN2Nogv4oQO7Sj1FAsyxhauR1GCIexAcrFyHlbmNtEN6mjmzzkHW8CfrdAuGE7KMobWiQQeCDsW3VCFCjR+9oCF9Yvuq0MRwibg/udCTY5Xb+KG9zKaEcW20TCxtqWEisx1Fyeo6g6Oomr/teo0Me8r7IAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704806168; c=relaxed/simple; bh=0UBJ1f/L4Iyq3HBuVwcde5XYVf6z2Tl2MdO7w7vkX9w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MNxZtu5Aafom94LTuMXc3PwgPLSiI2GCg92y2dytajWMou1lsTFeaLI2k4qr91RHcy8+CjAvoCxmIqoROKrB3E5OnlsNHaRKhm+MXJDGDK1Wnush++gV/mtLM1FMV0ub8JswFYdMgkWgfSy7Is/rAOiypesje4rH5aL3E36/wtI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40d5aefcc2fso33183545e9.0 for ; Tue, 09 Jan 2024 05:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1704806162; x=1705410962; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vXPgV06qKCv8n9hCtL7XaYVO8vlM2O9t1S+UdsCTXS0=; b=fN1y/Ct5eraCcYAJYIMjOKBQVvB4dKsPsqRs6oGGkBAvnT04crPiQ3M2ArPxjFcE8j b/1qgnBJNBTTDfDlaaaYLtN/qOi5/t8+blZAqc3C5Nfcfv3fY6njyhsVqFl5vAM3b8Yw Op93Z1hHHxYnBwNHR7UCVgqFW3A+D7vXC1O2sJTOw248Npqbtxu991NrMNM79jjViFJD 8oAInwMi3LigtPHiHJ847R4hM6U+Oc81Kfm4qYnVgEQu4DVn51EYyiKn7tvLWEaEfW0y AQ0Xc5++b6SlD35a1WOBJzLMDrAHMO14sxHnSylplfDZX3EztIH/gDtnNRG0fNYL2d53 qM1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704806162; x=1705410962; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vXPgV06qKCv8n9hCtL7XaYVO8vlM2O9t1S+UdsCTXS0=; b=nE+rxFKImwDZqhiEScVwNPd8vWQVL9LYCoZhNXywgHoYlxiE+riHJdIXm76nZa4rfA 6a0l+p5zqL7RkY3niUrtcPmg7QJ04BSFYOMD0slNuwfeNWwCHjjcYJuZybdMSnwwuBhX dXY+mwZKP488LeqI0MQrLx7fpWKetSJotxB9WwX9dtfIx4xaUeTYwRb4DbKbblh8iWF/ lM7eJJN8n54JU533aFBS+mnHsYCJSqEwkL64SRtsz3977LLjCjv7QkKyzy/UvTmxdDhs jajpT8rgHB+E+iVsx3AQMYM3KfHvPrlBVpSD9nP0jz0b3UYulFP38fUr3M2pA71507pH vE7g== X-Gm-Message-State: AOJu0YxBD+FD+686aRs8xfoPbKSpbUzrG2Km8px1jint07ygZh4Z4Qa/ UGhYOnYUdW0gqHsWyw04UfuUOh5iEReyYrYAx1O2oDhqag== X-Received: by 2002:a05:600c:4f4a:b0:40d:887b:f510 with SMTP id m10-20020a05600c4f4a00b0040d887bf510mr2545860wmq.86.1704806162031; Tue, 09 Jan 2024 05:16:02 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id g13-20020a05600c4ecd00b0040d91912f2csm3610935wmq.1.2024.01.09.05.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:16:01 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Preliminary cleanup in aliasing support code Date: Tue, 9 Jan 2024 14:16:00 +0100 Message-ID: <20240109131601.744998-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: 1787619253601242641 X-GMAIL-MSGID: 1787619253601242641 From: Eric Botcazou This declares an explicit temporary for the fields of the fat pointer type in gnat_to_gnu_entity and removes the GNU_ prefix of the parameters of the relate_alias_sets routine for the sake of brevity. No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Use a separate FLD local variable to hold the first field of the fat pointer type being built. * gcc-interface/gigi.h (relate_alias_sets): Remove GNU_ prefix on the first two parameters. * gcc-interface/utils.cc (relate_alias_sets): Likewise and adjust. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 27 +++++++++---------- gcc/ada/gcc-interface/gigi.h | 4 +-- gcc/ada/gcc-interface/utils.cc | 48 ++++++++++++++++------------------ 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 89a374fab1a..221baebb554 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -2111,7 +2111,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) tree *gnu_index_types = XALLOCAVEC (tree, ndim); tree *gnu_temp_fields = XALLOCAVEC (tree, ndim); tree gnu_max_size = size_one_node; - tree comp_type, tem, obj; + tree comp_type, fld, tem, obj; Entity_Id gnat_index; alias_set_type ptr_set = -1; int index; @@ -2184,11 +2184,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if the FIELD_DECLs are distinct as objects. */ if (COMPLETE_TYPE_P (gnu_fat_type)) { - tem = TYPE_FIELDS (gnu_fat_type); - if (TYPE_ALIAS_SET_KNOWN_P (TREE_TYPE (tem))) - ptr_set = TYPE_ALIAS_SET (TREE_TYPE (tem)); - TREE_TYPE (tem) = ptr_type_node; - TREE_TYPE (DECL_CHAIN (tem)) = gnu_ptr_template; + fld = TYPE_FIELDS (gnu_fat_type); + if (TYPE_ALIAS_SET_KNOWN_P (TREE_TYPE (fld))) + ptr_set = TYPE_ALIAS_SET (TREE_TYPE (fld)); + TREE_TYPE (fld) = ptr_type_node; + TREE_TYPE (DECL_CHAIN (fld)) = gnu_ptr_template; TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (gnu_fat_type)) = 0; for (tree t = gnu_fat_type; t; t = TYPE_NEXT_VARIANT (t)) SET_TYPE_UNCONSTRAINED_ARRAY (t, gnu_type); @@ -2197,15 +2197,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) { /* We make the fields addressable for the sake of compatibility with languages for which the regular fields are addressable. */ - tem + fld = create_field_decl (get_identifier ("P_ARRAY"), ptr_type_node, gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1); - DECL_CHAIN (tem) + DECL_CHAIN (fld) = create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template, gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1); - finish_fat_pointer_type (gnu_fat_type, tem); + finish_fat_pointer_type (gnu_fat_type, fld); SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_type); } @@ -2230,7 +2230,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) fields once we build them. */ tem = build3 (COMPONENT_REF, gnu_ptr_template, build0 (PLACEHOLDER_EXPR, gnu_fat_type), - DECL_CHAIN (TYPE_FIELDS (gnu_fat_type)), NULL_TREE); + DECL_CHAIN (fld), NULL_TREE); gnu_template_reference = build_unary_op (INDIRECT_REF, gnu_template_type, tem); TREE_READONLY (gnu_template_reference) = 1; @@ -2413,12 +2413,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) type since the implementation type may vary between constrained subtypes and unconstrained base type. */ if (Present (PAT)) - TREE_TYPE (TYPE_FIELDS (gnu_fat_type)) - = build_pointer_type_for_mode (tem, ptr_mode, true); + TREE_TYPE (fld) = build_pointer_type_for_mode (tem, ptr_mode, true); else - TREE_TYPE (TYPE_FIELDS (gnu_fat_type)) = build_pointer_type (tem); + TREE_TYPE (fld) = build_pointer_type (tem); if (ptr_set != -1) - TYPE_ALIAS_SET (TREE_TYPE (TYPE_FIELDS (gnu_fat_type))) = ptr_set; + TYPE_ALIAS_SET (TREE_TYPE (fld)) = ptr_set; /* If the maximum size doesn't overflow, use it. */ if (gnu_max_size diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 2a7320f0a4b..c1bc237e68e 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -158,14 +158,14 @@ enum alias_set_op ALIAS_SET_SUPERSET }; -/* Relate the alias sets of GNU_NEW_TYPE and GNU_OLD_TYPE according to OP. +/* Relate the alias sets of NEW_TYPE and OLD_TYPE according to OP. If this is a multi-dimensional array type, do this recursively. OP may be - ALIAS_SET_COPY: the new set is made a copy of the old one. - ALIAS_SET_SUPERSET: the new set is made a superset of the old one. - ALIAS_SET_SUBSET: the new set is made a subset of the old one. */ -extern void relate_alias_sets (tree gnu_new_type, tree gnu_old_type, +extern void relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op); /* Given GNAT_ENTITY, an object (constant, variable, parameter, exception) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index 17f6afd687d..bc063c20387 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -1823,7 +1823,7 @@ set_reverse_storage_order_on_pad_type (tree type) return canonicalize_pad_type (type); } -/* Relate the alias sets of GNU_NEW_TYPE and GNU_OLD_TYPE according to OP. +/* Relate the alias sets of NEW_TYPE and OLD_TYPE according to OP. If this is a multi-dimensional array type, do this recursively. OP may be @@ -1832,30 +1832,28 @@ set_reverse_storage_order_on_pad_type (tree type) - ALIAS_SET_SUBSET: the new set is made a subset of the old one. */ void -relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) +relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op) { /* Remove any padding from GNU_OLD_TYPE. It doesn't matter in the case of a one-dimensional array, since the padding has the same alias set as the field type, but if it's a multi-dimensional array, we need to see the inner types. */ - while (TREE_CODE (gnu_old_type) == RECORD_TYPE - && (TYPE_JUSTIFIED_MODULAR_P (gnu_old_type) - || TYPE_PADDING_P (gnu_old_type))) - gnu_old_type = TREE_TYPE (TYPE_FIELDS (gnu_old_type)); + while (TREE_CODE (old_type) == RECORD_TYPE + && (TYPE_JUSTIFIED_MODULAR_P (old_type) + || TYPE_PADDING_P (old_type))) + old_type = TREE_TYPE (TYPE_FIELDS (old_type)); /* Unconstrained array types are deemed incomplete and would thus be given alias set 0. Retrieve the underlying array type. */ - if (TREE_CODE (gnu_old_type) == UNCONSTRAINED_ARRAY_TYPE) - gnu_old_type - = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_old_type)))); - if (TREE_CODE (gnu_new_type) == UNCONSTRAINED_ARRAY_TYPE) - gnu_new_type - = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_new_type)))); - - if (TREE_CODE (gnu_new_type) == ARRAY_TYPE - && TREE_CODE (TREE_TYPE (gnu_new_type)) == ARRAY_TYPE - && TYPE_MULTI_ARRAY_P (TREE_TYPE (gnu_new_type))) - relate_alias_sets (TREE_TYPE (gnu_new_type), TREE_TYPE (gnu_old_type), op); + if (TREE_CODE (old_type) == UNCONSTRAINED_ARRAY_TYPE) + old_type = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (old_type)))); + if (TREE_CODE (new_type) == UNCONSTRAINED_ARRAY_TYPE) + new_type = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (new_type)))); + + if (TREE_CODE (new_type) == ARRAY_TYPE + && TREE_CODE (TREE_TYPE (new_type)) == ARRAY_TYPE + && TYPE_MULTI_ARRAY_P (TREE_TYPE (new_type))) + relate_alias_sets (TREE_TYPE (new_type), TREE_TYPE (old_type), op); switch (op) { @@ -1864,19 +1862,19 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) aliasing settings because this can break the aliasing relationship between the array type and its element type. */ if (flag_checking || flag_strict_aliasing) - gcc_assert (!(TREE_CODE (gnu_new_type) == ARRAY_TYPE - && TREE_CODE (gnu_old_type) == ARRAY_TYPE - && TYPE_NONALIASED_COMPONENT (gnu_new_type) - != TYPE_NONALIASED_COMPONENT (gnu_old_type))); + gcc_assert (!(TREE_CODE (new_type) == ARRAY_TYPE + && TREE_CODE (old_type) == ARRAY_TYPE + && TYPE_NONALIASED_COMPONENT (new_type) + != TYPE_NONALIASED_COMPONENT (old_type))); - TYPE_ALIAS_SET (gnu_new_type) = get_alias_set (gnu_old_type); + TYPE_ALIAS_SET (new_type) = get_alias_set (old_type); break; case ALIAS_SET_SUBSET: case ALIAS_SET_SUPERSET: { - alias_set_type old_set = get_alias_set (gnu_old_type); - alias_set_type new_set = get_alias_set (gnu_new_type); + alias_set_type old_set = get_alias_set (old_type); + alias_set_type new_set = get_alias_set (new_type); /* Do nothing if the alias sets conflict. This ensures that we never call record_alias_subset several times for the same pair @@ -1895,7 +1893,7 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) gcc_unreachable (); } - record_component_aliases (gnu_new_type); + record_component_aliases (new_type); } /* Record TYPE as a builtin type for Ada. NAME is the name of the type.