From patchwork Tue May 30 07:21:13 2023 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: 70292 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0886B3835E13 for ; Tue, 30 May 2023 07:26:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0886B3835E13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685431585; bh=AWbbHJ/Wbf706tROExW7uRvlLd6pEOtXXl2GO3u33jk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NcRrxRLCn0Tzf0xNe6xfZHczyhRo315ngcbgSO6ad/86S+M1lWJ7T+Fvw2Id9T/KP tNV0F1hcKz9RtLzPQ1jARyfRc7Rx/pShj44ASmiMLCNSYr/1vnvLkATbWzQ0VXXDJy pXzSm0IkGzLCjSKpnCjth1lS+epfaY/EDOJWtkWE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id E99DA38558B9 for ; Tue, 30 May 2023 07:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E99DA38558B9 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-30789a4c537so2461062f8f.0 for ; Tue, 30 May 2023 00:21:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685431275; x=1688023275; 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=AWbbHJ/Wbf706tROExW7uRvlLd6pEOtXXl2GO3u33jk=; b=G20YOLkf7HHYAIZpHlsUwhoPx39k0YhFgoGfefgNNCAYbTBijg63PY69JuPTPFGkFX VBkKx603rXmv3YfKlh89CEgLvWwEaxytgHeGT2Fy7sn2Aw8m24YFd2Fxo9xZpJyXQKpY TM2cR7MGfCBYi2ZOQ+zapyTnDEUqQbTJwQxYzhfScyjQURBz8bkDCDiKC/HhVEzk85qc tLHvta2OSxiXdYa5i9baf85netPUfU92W4IHwpl23j0t4208nR7SEKmjYdG/33SU8SxZ uClQSdaxNawZxtTzbiZ66ANujcI/HvxIlZ115kQS6mMtfaHk95m4KFYnZhWLxErA7eUw H/zw== X-Gm-Message-State: AC+VfDw7Z/1iT+CgdjnZVDInq4BMkYZ9L7L7sRWlzRBIl5+8FBXELEuQ oCtelaqXzxlw3QPZPouRNmpZ+cJNqNObE074VoI/yA== X-Google-Smtp-Source: ACHHUZ71qgl73pLCu9oscc/LfBfWA9GMFjQN2dqxABPtbjoJJ1/rR6hXnXLqUGODcFSkaVuaV7XGUQ== X-Received: by 2002:adf:e702:0:b0:306:3286:69a2 with SMTP id c2-20020adfe702000000b00306328669a2mr776173wrm.48.1685431274859; Tue, 30 May 2023 00:21:14 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:7733:a608:a415:6b2a]) by smtp.gmail.com with ESMTPSA id j12-20020a5d564c000000b0030af31c8c63sm1619837wrw.47.2023.05.30.00.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 00:21:14 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Adjust again the implementation of storage models Date: Tue, 30 May 2023 09:21:13 +0200 Message-Id: <20230530072113.2500553-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Eric Botcazou The code generator must now be prepared to translate assignment statements to objects allocated with a storage model and that are not initialized yet. gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) : Tweak. (gnat_to_gnu) : Declare a local variable. For a target with a storage model, use the Actual_Designated_Subtype to compute the size if it is present. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/trans.cc | 51 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 92c8dc33af8..4e5f26305f5 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -1945,24 +1945,20 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) /* If this is a dereference and we have a special dynamic constrained subtype on the prefix, use it to compute the size; otherwise, use the designated subtype. */ - if (Nkind (gnat_prefix) == N_Explicit_Dereference) + if (Nkind (gnat_prefix) == N_Explicit_Dereference + && Present (Actual_Designated_Subtype (gnat_prefix))) { - Node_Id gnat_actual_subtype - = Actual_Designated_Subtype (gnat_prefix); + tree gnu_actual_obj_type + = gnat_to_gnu_type (Actual_Designated_Subtype (gnat_prefix)); tree gnu_ptr_type = TREE_TYPE (gnat_to_gnu (Prefix (gnat_prefix))); - if (TYPE_IS_FAT_OR_THIN_POINTER_P (gnu_ptr_type) - && Present (gnat_actual_subtype)) - { - tree gnu_actual_obj_type - = gnat_to_gnu_type (gnat_actual_subtype); - gnu_type - = build_unc_object_type_from_ptr (gnu_ptr_type, - gnu_actual_obj_type, - get_identifier ("SIZE"), - false); - } + if (TYPE_IS_FAT_OR_THIN_POINTER_P (gnu_ptr_type)) + gnu_type + = build_unc_object_type_from_ptr (gnu_ptr_type, + gnu_actual_obj_type, + get_identifier ("SIZE"), + false); } gnu_result = TYPE_SIZE (gnu_type); @@ -7378,13 +7374,13 @@ gnat_to_gnu (Node_Id gnat_node) /* Otherwise we need to build the assignment statement manually. */ else { + const Node_Id gnat_name = Name (gnat_node); const Node_Id gnat_expr = Expression (gnat_node); const Node_Id gnat_inner = Nkind (gnat_expr) == N_Qualified_Expression ? Expression (gnat_expr) : gnat_expr; - const Entity_Id gnat_type - = Underlying_Type (Etype (Name (gnat_node))); + const Entity_Id gnat_type = Underlying_Type (Etype (gnat_name)); const bool use_memset_p = Is_Array_Type (gnat_type) && Nkind (gnat_inner) == N_Aggregate @@ -7409,8 +7405,8 @@ gnat_to_gnu (Node_Id gnat_node) gigi_checking_assert (!Do_Range_Check (gnat_expr)); - get_atomic_access (Name (gnat_node), &aa_type, &aa_sync); - get_storage_model_access (Name (gnat_node), &gnat_smo); + get_atomic_access (gnat_name, &aa_type, &aa_sync); + get_storage_model_access (gnat_name, &gnat_smo); /* If an outer atomic access is required on the LHS, build the load- modify-store sequence. */ @@ -7427,15 +7423,26 @@ gnat_to_gnu (Node_Id gnat_node) else if (Present (gnat_smo) && Present (Storage_Model_Copy_To (gnat_smo))) { + tree gnu_size; + /* We obviously cannot use memset in this case. */ gcc_assert (!use_memset_p); - /* We cannot directly move between nonnative storage models. */ - tree t = remove_conversions (gnu_rhs, false); - gcc_assert (TREE_CODE (t) != LOAD_EXPR); + /* If this is a dereference with a special dynamic constrained + subtype on the node, use it to compute the size. */ + if (Nkind (gnat_name) == N_Explicit_Dereference + && Present (Actual_Designated_Subtype (gnat_name))) + { + tree gnu_actual_obj_type + = gnat_to_gnu_type (Actual_Designated_Subtype (gnat_name)); + gnu_size = TYPE_SIZE_UNIT (gnu_actual_obj_type); + } + else + gnu_size = NULL_TREE; gnu_result - = build_storage_model_store (gnat_smo, gnu_lhs, gnu_rhs); + = build_storage_model_store (gnat_smo, gnu_lhs, gnu_rhs, + gnu_size); } /* Or else, use memset when the conditions are met. This has already