From patchwork Thu Jul 13 08:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1684310vqm; Thu, 13 Jul 2023 01:55:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHF2Qn9ATMFZK/wHk+ovW7+2hhpBqGKkjx5N3OLFqkBsJqD0oSpicvDdptLA0bzSZA6CLYv X-Received: by 2002:a2e:9d84:0:b0:2b6:e76b:1e50 with SMTP id c4-20020a2e9d84000000b002b6e76b1e50mr862696ljj.41.1689238519949; Thu, 13 Jul 2023 01:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238519; cv=none; d=google.com; s=arc-20160816; b=OkOAO+RdAiAqIinsnzyowgk1EpRbxCeD2l3qeYpjhMb5Bug91OBmc+YZIm3/33KP0U kzGWrU8XxAV0Cbn3NIlcYlADmFgKkXcg0Fm4RykmNhQPp6X6hAHhl7VbcylYNSbC+ug7 L/jmIdliTAjoMbZ4fwYbbTQklcb7FmaQNaB6/CtrKqFp9fr7xaOCndIKUhYfAr87ekn0 i3QIoYvOgsM6OZSLnwFz7S5XFtCtLY73bjRSJeDlDPEM25AHg9NA6Ignd9t0XIO4hhFF Q/9X8Z0rxraU3qw7B2dtT07RcweTdpQTmMcgWxyrugKhj9JMyyVBpj47vBg52j/bpR58 CHiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=oLjNZRwgrdxP0l7wa+m3NfAgGRPCXpHJnyNtZ9xV1hY=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=00+J9I/27Kgn54tCEqrX/WcTCzj6rIZdxtKl0H9QHsT5Or3UReeT8vfdSx0225sNMr YNIBZFps7ZemnH6S2gOJXe2k8nzkHx/hbfDUG4LLlbos9hxeijKFW9u/OctUGW4cVWsF 6FfgN1TUszqATMGvoC2W/8G1bHZhhVK3nNoEWF3QbCXq0CIAPY9S9/2mSbq+6KFCF7iG HW3Udem7C+q2BBXTX07FNtpiSMY0/UYu/SNcweWpsSWg3xmdprkUgRY4b/h44PTUxiLA YWkPFiPKRMPcasqKsAPJK0vFQITq2AWFALDIMwyCFEa0g9xl/H3ZdhgqtUTMd14nOVRq wb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dxYAbz8R; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id by18-20020a170906a2d200b0098d807c0e8fsi6770298ejb.264.2023.07.13.01.55.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:55:19 -0700 (PDT) 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=dxYAbz8R; 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 0114F3852656 for ; Thu, 13 Jul 2023 08:53:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0114F3852656 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238425; bh=oLjNZRwgrdxP0l7wa+m3NfAgGRPCXpHJnyNtZ9xV1hY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=dxYAbz8R8DMZzXV+Rz5b017IlF4Zvmm9MwtP1U5YXdOZYcpFKMJbH75z4Vy90A3Y8 CJ1qDDL6UxUicqtdeBveLly4y37PXow74k/lzh7JFeIeNPfa+Fcfl5y+toTbQRLW2d yK26WbAQ/OL65sKa1wpoPJACIC41+UJVKbgDkynI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id DB8733858C41 for ; Thu, 13 Jul 2023 08:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB8733858C41 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs42q0yVK; Thu, 13 Jul 2023 10:52:42 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:42 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 01/14] fortran: Outline final procedure pointer evaluation Date: Thu, 13 Jul 2023 10:52:23 +0200 Message-Id: <20230713085236.330222-2-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771294970666952652 X-GMAIL-MSGID: 1771294970666952652 gcc/fortran/ChangeLog: * trans.cc (get_final_proc_ref): New function. (gfc_build_final_call): Outline the pointer evaluation code to get_final_proc_ref. --- gcc/fortran/trans.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index f1a3aacd850..b5f7b16eda3 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1085,6 +1085,21 @@ gfc_call_free (tree var) } +/* Generate the data reference to the finalization procedure pointer passed as + argument in FINAL_WRAPPER. */ + +static void +get_final_proc_ref (gfc_se *se, gfc_expr *final_wrapper) +{ + gcc_assert (final_wrapper->expr_type == EXPR_VARIABLE); + + gfc_conv_expr (se, final_wrapper); + + if (POINTER_TYPE_P (TREE_TYPE (se->expr))) + se->expr = build_fold_indirect_ref_loc (input_location, se->expr); +} + + /* Build a call to a FINAL procedure, which finalizes "var". */ static tree @@ -1092,19 +1107,19 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, bool fini_coarray, gfc_expr *class_size) { stmtblock_t block; + gfc_se final_se; gfc_se se; tree final_fndecl, array, size, tmp; symbol_attribute attr; - gcc_assert (final_wrapper->expr_type == EXPR_VARIABLE); gcc_assert (var); gfc_start_block (&block); - gfc_init_se (&se, NULL); - gfc_conv_expr (&se, final_wrapper); - final_fndecl = se.expr; - if (POINTER_TYPE_P (TREE_TYPE (final_fndecl))) - final_fndecl = build_fold_indirect_ref_loc (input_location, final_fndecl); + + gfc_init_se (&final_se, NULL); + get_final_proc_ref (&final_se, final_wrapper); + gfc_add_block_to_block (&block, &final_se.pre); + final_fndecl = final_se.expr; if (ts.type == BT_DERIVED) { From patchwork Thu Jul 13 08:52:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1684545vqm; Thu, 13 Jul 2023 01:56:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGI7ZOca0MB/SSkzKSd6F9KLaJgUWxisARM/lfqp74rFh9+U7qCXl1JZyBpDqli2nv938D/ X-Received: by 2002:a05:6402:1b1a:b0:51e:338f:863b with SMTP id by26-20020a0564021b1a00b0051e338f863bmr1155010edb.11.1689238564777; Thu, 13 Jul 2023 01:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238564; cv=none; d=google.com; s=arc-20160816; b=D5TNIcLC9Ej+G2mAnoIyJvkE5rM1pcLmYFhPbmOWzHu5F/Y2Wkl2uJX2up/C6QV3QV IfOvyGMFHtZEmvrzrVZTlQN+dhzSnP46TQt+1YgPdaTRfXZhZ9y1gW38V7MK1ezN5EiH DHujX92EwS8QbhdGg2ciyUOd3yFhqAS3c7C5kHtWlwSyNKcQkBwxfUbM+p3TJ3E0a59X EofZacq0/B1a2HyomZJL1TJ+XrPjJ+TA1aWtotCYRHBJdX4PZ52aAtYxpA6zKIrw0uHb uN3NwPLnEhaVVCp0G8Uxu+hYal3Q6JEKRGUEthJwPCMX4HTzslEhB024CM3ZbfxnrhyE qrBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=BzqHr3hrvLxaKMHiLjF9Tcm9sNzrf5imjeNguchuaH0=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=jBxt7px/9JbFx/gRp16AjrPlIw571a+Og3446NYV1egRt/phj8kjZFaPCPJg9ZnVPd am10BGYrCmIw11J34Zsk21kxBVA8NepqQG+D8zjw9ZUNnus0VRUQ/L3Fnzk8yr7H5g2g ypWpUVoqfIRculGo5rLuJ+Fwb4xoRJEpCLCMWm202SRbwyiXKNdozyfVzbOdDBkJq+Ak sZzUn06iclC9N3c0c0zpjQxUlns+VQjLtFYGUbiZJ2W5mpng0DcIkYE3U//XsyysAhcL woqI4SFBZv5kHYcEIPEfd2X6XC+fPHknXeDGup1pWDHpbYRQOoR4B1wttxNRySnAyE34 F+NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZLcT+j00; 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 b17-20020a05640202d100b0051bf5123b01si7032532edx.251.2023.07.13.01.56.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:56:04 -0700 (PDT) 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=ZLcT+j00; 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 C1AEB3854E97 for ; Thu, 13 Jul 2023 08:53:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1AEB3854E97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238439; bh=BzqHr3hrvLxaKMHiLjF9Tcm9sNzrf5imjeNguchuaH0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZLcT+j00tWEMcjm5iE/V/mXSmAntYXSlVXbv5kTdW3+IM/Q33VR4Kke1FK6KrwsO3 GwKX+EVbwYPn7ahuPuvTP8ss85Hqj6hyPBfr7Yr9E1ccIw8sgGVvcwzilrJyg3pnFB W8JlU5iReiA95vh3g9cYnc+N8lON1Eepsn9sUD4o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id E460E385841A for ; Thu, 13 Jul 2023 08:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E460E385841A Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs43q0yVO; Thu, 13 Jul 2023 10:52:43 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:43 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 02/14] fortran: Outline element size evaluation Date: Thu, 13 Jul 2023 10:52:24 +0200 Message-Id: <20230713085236.330222-3-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295016988620817 X-GMAIL-MSGID: 1771295016988620817 gcc/fortran/ChangeLog: * trans.cc (get_elem_size): New function. (gfc_build_final_call): Outline the element size evaluation to get_elem_size. --- gcc/fortran/trans.cc | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index b5f7b16eda3..1e4779f94af 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1100,6 +1100,30 @@ get_final_proc_ref (gfc_se *se, gfc_expr *final_wrapper) } +/* Generate the code to obtain the value of the element size whose expression + is passed as argument in CLASS_SIZE. */ + +static void +get_elem_size (gfc_se *se, gfc_typespec *ts, gfc_expr *class_size) +{ + gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS); + + if (ts->type == BT_DERIVED) + { + gcc_assert (!class_size); + se->expr = gfc_typenode_for_spec (ts); + se->expr = TYPE_SIZE_UNIT (se->expr); + se->expr = fold_convert (gfc_array_index_type, se->expr); + } + else + { + gcc_assert (class_size); + gfc_conv_expr (se, class_size); + gcc_assert (se->post.head == NULL_TREE); + } +} + + /* Build a call to a FINAL procedure, which finalizes "var". */ static tree @@ -1107,7 +1131,7 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, bool fini_coarray, gfc_expr *class_size) { stmtblock_t block; - gfc_se final_se; + gfc_se final_se, size_se; gfc_se se; tree final_fndecl, array, size, tmp; symbol_attribute attr; @@ -1121,15 +1145,13 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, gfc_add_block_to_block (&block, &final_se.pre); final_fndecl = final_se.expr; + gfc_init_se (&size_se, NULL); + get_elem_size (&size_se, &ts, class_size); + gfc_add_block_to_block (&block, &size_se.pre); + size = size_se.expr; + if (ts.type == BT_DERIVED) { - tree elem_size; - - gcc_assert (!class_size); - elem_size = gfc_typenode_for_spec (&ts); - elem_size = TYPE_SIZE_UNIT (elem_size); - size = fold_convert (gfc_array_index_type, elem_size); - gfc_init_se (&se, NULL); se.want_pointer = 1; if (var->rank) @@ -1155,12 +1177,6 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, else { gfc_expr *array_expr; - gcc_assert (class_size); - gfc_init_se (&se, NULL); - gfc_conv_expr (&se, class_size); - gfc_add_block_to_block (&block, &se.pre); - gcc_assert (se.post.head == NULL_TREE); - size = se.expr; array_expr = gfc_copy_expr (var); gfc_init_se (&se, NULL); From patchwork Thu Jul 13 08:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1684641vqm; Thu, 13 Jul 2023 01:56:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlG04WSVrggLmMEBq5CY9VhfdqRrywpca+dA0xlLCegr9JoOU8J5GW7ySwhs3ooy8z5uV81I X-Received: by 2002:a17:906:6c8f:b0:994:356a:2034 with SMTP id s15-20020a1709066c8f00b00994356a2034mr929490ejr.43.1689238579403; Thu, 13 Jul 2023 01:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238579; cv=none; d=google.com; s=arc-20160816; b=lB3o5gq1G4ODVBDEjFSURPZYrjivfcN/nMoXTR2dYhrJMZ0Y/6YsWiBESm28n7nQuC rPFMK1ValxpntdTqq98sN1pRbi+0/7Zu6gdn1+ea3YMo9w3UfZVFqImwDjcpfkjotRT9 BH2WyhG6g235ndgTnJ/4du4HYqYyYmq3dcPwzlzEi3mz8nd6TRwgQo/rNBRNhzYgdju+ MThdS4W8ogAGBTURQ2KK309+4yhRbUQ0bq1YdjPFiOqi6bxS9HbmInHS+ro+9mGfLhpE TLGaw5BFtdcTMjE15o3YVvsT6scwOS7Katmsj1owW765t7t5QLzux4UgHVyw92IYRWOY wpug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=tRHq5Jsff0GvwwRL9hVrthjZtLxWWndbU9ZVtN0i8ZQ=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=NQpKwDBMIXEvwoCgEwFqwX9f72y1SfoYx/sX/OfZbkLaAdtxtCIG7J9B6AS7QNVk4D fPWBEGKe9SlFMZ0MjiQHMNYt18h2rXvYgWwnrrcDdTw5aWKorrIPGEa1oo/vXpf4f4Ih Baf2GxE+w6efyEBRQreju/GDtEC6kXfphS5Tt7evWl3UdmjXZpUtWuPhrpV09JSK1ndN EYjFEuPc0maIet2DclFtL7SzGQYSiLn1RKM4rR71l+e7rF9t8StVEC2U+KZPAX/Lytrc r4xQHoMmJTZvaerP8C2XWAHfb0NvQ0C/+Ttwq8VHSYwGACKNPLLj+483lGuhWVxKAXZu s0Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Q5LKN29X; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lw28-20020a170906bcdc00b0098e1263aadbsi7551236ejb.100.2023.07.13.01.56.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:56:19 -0700 (PDT) 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=Q5LKN29X; 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 142F53854EBD for ; Thu, 13 Jul 2023 08:54:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 142F53854EBD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238445; bh=tRHq5Jsff0GvwwRL9hVrthjZtLxWWndbU9ZVtN0i8ZQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Q5LKN29XZYpGVR4MM8eu8ukZp6emBQwnH8/oNR2x6xOzv1WKuISls0kp5c3skl4TN uEnDhk6aze2njC87ScvOyORIDLorR8+DMLn5etv+SS8jb/OU8uUALOHdWK5rPSBbUw 0UKWulbqCZcexw5VDeFlYdFaMfu+YLSajTfkaZG8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id E71003858422 for ; Thu, 13 Jul 2023 08:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E71003858422 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs43q0yVQ; Thu, 13 Jul 2023 10:52:43 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:43 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 03/14] fortran: Outline data reference descriptor evaluation Date: Thu, 13 Jul 2023 10:52:25 +0200 Message-Id: <20230713085236.330222-4-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295032897294767 X-GMAIL-MSGID: 1771295032897294767 gcc/fortran/ChangeLog: * trans.cc (get_var_descr): New function. (gfc_build_final_call): Outline the data reference descriptor evaluation code to get_var_descr. --- gcc/fortran/trans.cc | 149 ++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 66 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 1e4779f94af..9807b7eb9d9 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1124,6 +1124,83 @@ get_elem_size (gfc_se *se, gfc_typespec *ts, gfc_expr *class_size) } +/* Generate the data reference (array) descriptor corresponding to the + expression passed as argument in VAR. Use type in TS to pilot code + generation. */ + +static void +get_var_descr (gfc_se *se, gfc_typespec *ts, gfc_expr *var) +{ + gfc_se tmp_se; + symbol_attribute attr; + + gcc_assert (var); + + gfc_init_se (&tmp_se, NULL); + + if (ts->type == BT_DERIVED) + { + tmp_se.want_pointer = 1; + if (var->rank) + { + tmp_se.descriptor_only = 1; + gfc_conv_expr_descriptor (&tmp_se, var); + } + else + { + gfc_conv_expr (&tmp_se, var); +// gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); + + /* No copy back needed, hence set attr's allocatable/pointer + to zero. */ + gfc_clear_attr (&attr); + tmp_se.expr = gfc_conv_scalar_to_descriptor (&tmp_se, tmp_se.expr, + attr); + gcc_assert (tmp_se.post.head == NULL_TREE); + } + } + else + { + gfc_expr *array_expr; + + array_expr = gfc_copy_expr (var); + + tmp_se.want_pointer = 1; + if (array_expr->rank) + { + gfc_add_class_array_ref (array_expr); + tmp_se.descriptor_only = 1; + gfc_conv_expr_descriptor (&tmp_se, array_expr); + } + else + { + gfc_add_data_component (array_expr); + gfc_conv_expr (&tmp_se, array_expr); + gcc_assert (tmp_se.post.head == NULL_TREE); + + if (!gfc_is_coarray (array_expr)) + { + /* No copy back needed, hence set attr's allocatable/pointer + to zero. */ + gfc_clear_attr (&attr); + tmp_se.expr = gfc_conv_scalar_to_descriptor (&tmp_se, tmp_se.expr, + attr); + } + gcc_assert (tmp_se.post.head == NULL_TREE); + } + gfc_free_expr (array_expr); + } + + if (!POINTER_TYPE_P (TREE_TYPE (tmp_se.expr))) + tmp_se.expr = gfc_build_addr_expr (NULL, tmp_se.expr); + + gfc_add_block_to_block (&se->pre, &tmp_se.pre); + gfc_add_block_to_block (&se->post, &tmp_se.post); + se->expr = tmp_se.expr; +} + + + /* Build a call to a FINAL procedure, which finalizes "var". */ static tree @@ -1131,10 +1208,8 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, bool fini_coarray, gfc_expr *class_size) { stmtblock_t block; - gfc_se final_se, size_se; - gfc_se se; + gfc_se final_se, size_se, desc_se; tree final_fndecl, array, size, tmp; - symbol_attribute attr; gcc_assert (var); @@ -1150,74 +1225,16 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, gfc_add_block_to_block (&block, &size_se.pre); size = size_se.expr; - if (ts.type == BT_DERIVED) - { - gfc_init_se (&se, NULL); - se.want_pointer = 1; - if (var->rank) - { - se.descriptor_only = 1; - gfc_conv_expr_descriptor (&se, var); - array = se.expr; - } - else - { - gfc_conv_expr (&se, var); -// gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); - array = se.expr; + gfc_init_se (&desc_se, NULL); + get_var_descr (&desc_se, &ts, var); + gfc_add_block_to_block (&block, &desc_se.pre); + array = desc_se.expr; - /* No copy back needed, hence set attr's allocatable/pointer - to zero. */ - gfc_clear_attr (&attr); - gfc_init_se (&se, NULL); - array = gfc_conv_scalar_to_descriptor (&se, array, attr); - gcc_assert (se.post.head == NULL_TREE); - } - } - else - { - gfc_expr *array_expr; - - array_expr = gfc_copy_expr (var); - gfc_init_se (&se, NULL); - se.want_pointer = 1; - if (array_expr->rank) - { - gfc_add_class_array_ref (array_expr); - se.descriptor_only = 1; - gfc_conv_expr_descriptor (&se, array_expr); - array = se.expr; - } - else - { - gfc_add_data_component (array_expr); - gfc_conv_expr (&se, array_expr); - gfc_add_block_to_block (&block, &se.pre); - gcc_assert (se.post.head == NULL_TREE); - array = se.expr; - - if (!gfc_is_coarray (array_expr)) - { - /* No copy back needed, hence set attr's allocatable/pointer - to zero. */ - gfc_clear_attr (&attr); - gfc_init_se (&se, NULL); - array = gfc_conv_scalar_to_descriptor (&se, array, attr); - } - gcc_assert (se.post.head == NULL_TREE); - } - gfc_free_expr (array_expr); - } - - if (!POINTER_TYPE_P (TREE_TYPE (array))) - array = gfc_build_addr_expr (NULL, array); - - gfc_add_block_to_block (&block, &se.pre); tmp = build_call_expr_loc (input_location, final_fndecl, 3, array, size, fini_coarray ? boolean_true_node : boolean_false_node); - gfc_add_block_to_block (&block, &se.post); + gfc_add_block_to_block (&block, &desc_se.post); gfc_add_expr_to_block (&block, tmp); return gfc_finish_block (&block); } From patchwork Thu Jul 13 08:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1685375vqm; Thu, 13 Jul 2023 01:58:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHEt0NXtD8rprre5fYzbWUn4BnJuFTFfJvPrlHWtTCJjk70d9qzJQ/FOxUJfBNJQYZsDv6n X-Received: by 2002:a17:906:64d6:b0:97e:56d5:b885 with SMTP id p22-20020a17090664d600b0097e56d5b885mr841576ejn.60.1689238705014; Thu, 13 Jul 2023 01:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238705; cv=none; d=google.com; s=arc-20160816; b=ZqJJ84G1X/WUGnx2bQaR5Z5guwpiCi/m5tx6FWwaYP7Z7cxf5+4dOs/1L1dU2a8kYZ EPGyAvGvCB33i6BQPohvK/wNarBAo2Rz4GiTa9gCseMthQI6qhDUqMAsQhpIG4FO8H7n FpdxEpcemU3Mypfhs+NIEwoOqCdLdfyEFrvT0Otd3Q11SX7fuRwS+xnqJ8JoOYgzYUJ5 e45aIwiN5OBGnDTFwOQ64jMzleFQgsH8CW8hK2PGDdo2FyVN8ME0+mftty/kNkS2Cmy7 rgPCozogaQcBiqtLR1+870EYl8uNi62wCUE5hLTf4tGfigBcagH+ekC646W3/DvS17yk WJdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=peCu/E1yhlONrTkpagxlff5OaQJaxpY+As0ra6EfrUE=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=Uq7rm9MwE75oEivm5fj2iFLeFlRHOP9AGCnYoCW6DseQytnMEKURd3V8crXvBjy2Ud lNrsgDOALu4L5sjC5qEkDYkHh20qO34aeP/VqEzhMqeMWZ6/GOoI3QJkf8KmEX7u89xk gnq1Gh2boZjYAvUud3yaWuVyXJmYkcGvLQ3/6LU163mOJkG7XB7P2NfrUu4Swf/bRwU9 ocwqYhA4X4rts4CSdu1HUQ8sIz41DMpd1BhrkghigL28P6Q63dei33bF9ibQFT7PWU29 FQB+mRb24vNm0CCnua8g2rToMsecGygP3GdJiAGhPC/PxnkrtM7URvFuNB+Qv8O+jRmR cJtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=I4ivxNb8; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f3-20020a170906c08300b009937cf92693si7209116ejz.427.2023.07.13.01.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:58:25 -0700 (PDT) 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=I4ivxNb8; 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 0C98A385414F for ; Thu, 13 Jul 2023 08:54:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C98A385414F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238485; bh=peCu/E1yhlONrTkpagxlff5OaQJaxpY+As0ra6EfrUE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=I4ivxNb8UKAU3INjqWsNOCh3b2JxYD/6x15wf2mNZ4yz9/XQLfrlQUypbec1jDVUN /8Ru+UzERSH+Utc5B0/ttGDbALRxOr8BFcgazxXmCvVn1HVoFZSh2TkJzhK9oMv+Mk PJSaJRjz7CbInP3Zsyne1D4vzuV1LqUkASBY8vK8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id 1003B3858430 for ; Thu, 13 Jul 2023 08:52:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1003B3858430 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs43q0yVU; Thu, 13 Jul 2023 10:52:43 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:43 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 04/14] fortran: Inline gfc_build_final_call Date: Thu, 13 Jul 2023 10:52:26 +0200 Message-Id: <20230713085236.330222-5-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295164002766078 X-GMAIL-MSGID: 1771295164002766078 Function gfc_build_final_call has been simplified, inline it. gcc/fortran/ChangeLog: * trans.cc (gfc_build_final_call): Inline... (gfc_add_finalizer_call): ... to its one caller. --- gcc/fortran/trans.cc | 66 +++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 9807b7eb9d9..f8ca388ab9f 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1201,45 +1201,6 @@ get_var_descr (gfc_se *se, gfc_typespec *ts, gfc_expr *var) -/* Build a call to a FINAL procedure, which finalizes "var". */ - -static tree -gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, - bool fini_coarray, gfc_expr *class_size) -{ - stmtblock_t block; - gfc_se final_se, size_se, desc_se; - tree final_fndecl, array, size, tmp; - - gcc_assert (var); - - gfc_start_block (&block); - - gfc_init_se (&final_se, NULL); - get_final_proc_ref (&final_se, final_wrapper); - gfc_add_block_to_block (&block, &final_se.pre); - final_fndecl = final_se.expr; - - gfc_init_se (&size_se, NULL); - get_elem_size (&size_se, &ts, class_size); - gfc_add_block_to_block (&block, &size_se.pre); - size = size_se.expr; - - gfc_init_se (&desc_se, NULL); - get_var_descr (&desc_se, &ts, var); - gfc_add_block_to_block (&block, &desc_se.pre); - array = desc_se.expr; - - tmp = build_call_expr_loc (input_location, - final_fndecl, 3, array, - size, fini_coarray ? boolean_true_node - : boolean_false_node); - gfc_add_block_to_block (&block, &desc_se.post); - gfc_add_expr_to_block (&block, tmp); - return gfc_finish_block (&block); -} - - bool gfc_add_comp_finalizer_call (stmtblock_t *block, tree decl, gfc_component *comp, bool fini_coarray) @@ -1408,8 +1369,31 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gcc_assert (final_expr->expr_type == EXPR_VARIABLE); - tmp = gfc_build_final_call (expr->ts, final_expr, expr, - false, elem_size); + stmtblock_t tmp_block; + gfc_start_block (&tmp_block); + + gfc_se final_se; + gfc_init_se (&final_se, NULL); + get_final_proc_ref (&final_se, final_expr); + gfc_add_block_to_block (&tmp_block, &final_se.pre); + + gfc_se size_se; + gfc_init_se (&size_se, NULL); + get_elem_size (&size_se, &expr->ts, elem_size); + gfc_add_block_to_block (&tmp_block, &size_se.pre); + + gfc_se desc_se; + gfc_init_se (&desc_se, NULL); + get_var_descr (&desc_se, &expr->ts, expr); + gfc_add_block_to_block (&tmp_block, &desc_se.pre); + + tmp = build_call_expr_loc (input_location, final_se.expr, 3, + desc_se.expr, size_se.expr, + boolean_false_node); + + gfc_add_block_to_block (&tmp_block, &desc_se.post); + gfc_add_expr_to_block (&tmp_block, tmp); + tmp = gfc_finish_block (&tmp_block); if (expr->ts.type == BT_CLASS && !has_finalizer) { From patchwork Thu Jul 13 08:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1686826vqm; Thu, 13 Jul 2023 02:01:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcYOZjgblWdN53oAnEdvTTH/SfSJQqruaR3u9FmtsBzyY9x/G6u7vmCD8Q+AK5YZVnRf7D X-Received: by 2002:a17:906:4a44:b0:98e:2423:708 with SMTP id a4-20020a1709064a4400b0098e24230708mr757139ejv.62.1689238877801; Thu, 13 Jul 2023 02:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238877; cv=none; d=google.com; s=arc-20160816; b=NEYdNY3TVh8MyvCzGbF+x+/Iw9HbxDtU9d/bbqqzwCOlR4nxiQ/1xHLQ0Zphv9lp5w bYRd36pKMciGm3TKneqE+JT1pqACyqfQAjLolLYY6JIMsKqu1AMGmYMG367cQ/fFlh0f wjhgQQVyHxWOnXFzXtvppLcreHuMZ0L6N4R/25So78/L7fAir7HE0xYwm4A/8XDIb9ys cHY2TvzNfUA4SZSF62yH4A/LOIKj/nu4CZEy4oAK5Qq5aygYhPPj/3SDBbh7R/PGzMvd 8YBW2aWCixvhuyaOkjyrTbe6rMJeo3BB3La6F7z+ROtU2RcvGoIvDykK4lma6VKdkz8f fgbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=7nwXXGawt6y99sPvGpAXwtXoq8nxFKIF5Bon2KnbnzA=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=OW0k0UQ95oyZsYTVvL+cmJdMs7ZRehkfY3lerwwv4MaoPrA9wkVjO717M9XcoxA/4s jqJJZM/ce3H+V5ucqsrkRfnOutVkeppFPRDvcQeegaRL5VIQxTHRU4AnKSXl0teIUlQj kX73Yvv3PM1slEkXDgUIHbmBxPorOZu3gKRVlR9SIOC2tOXkinaqkO1uU1oCUuG4Wnnx rQIFJaRY0T74qui3mZ8ClXTqGCWQZiJ1wkqYmZ+dfV9udh5WMQtpUhUUKR8P6htI4JHA R93fnBH7vsfs17CSI6XYJ4spGYLa31wlAD0AZxCQN5m7oLSuYsHTiqF+8n0lWt2MbN6H pw6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XEVRPGMr; 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 u9-20020a1709067d0900b00988e942e12csi6979245ejo.716.2023.07.13.02.01.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:01:17 -0700 (PDT) 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=XEVRPGMr; 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 B02FC385266A for ; Thu, 13 Jul 2023 08:55:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B02FC385266A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238541; bh=7nwXXGawt6y99sPvGpAXwtXoq8nxFKIF5Bon2KnbnzA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XEVRPGMrCaczmhpJhxVLv1mrLRgEzRkReJMf/rSmOL4M0Jheb1rQ0sr83nIyIASnw Er0uGDO136KsULbYDqeInVVyEUZlN4pMZbHvrpbCOa0ehdLc89bjQLV5861RMpvhM1 +M0Lwc+6aDKkCvcRQFIwf2uv7NH7KhrSwqgzM+kI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id 3B195385828E for ; Thu, 13 Jul 2023 08:52:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B195385828E Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs43q0yVW; Thu, 13 Jul 2023 10:52:43 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:43 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 05/14] fortran: Add missing cleanup blocks Date: Thu, 13 Jul 2023 10:52:27 +0200 Message-Id: <20230713085236.330222-6-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295345791001666 X-GMAIL-MSGID: 1771295345791001666 Move cleanup code for the data descriptor after the finalization code as it makes more sense to have it after. Other cleanup blocks should be empty (element size and final pointer are just data references), but add them by the way, just in case. gcc/fortran/ChangeLog: * trans.cc (gfc_add_finalizer_call): Add post code for desc_se after the finalizer call. Add post code for final_se and size_se as well. --- gcc/fortran/trans.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index f8ca388ab9f..5c953a07533 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1391,8 +1391,12 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) desc_se.expr, size_se.expr, boolean_false_node); - gfc_add_block_to_block (&tmp_block, &desc_se.post); gfc_add_expr_to_block (&tmp_block, tmp); + + gfc_add_block_to_block (&tmp_block, &desc_se.post); + gfc_add_block_to_block (&tmp_block, &size_se.post); + gfc_add_block_to_block (&tmp_block, &final_se.post); + tmp = gfc_finish_block (&tmp_block); if (expr->ts.type == BT_CLASS && !has_finalizer) From patchwork Thu Jul 13 08:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1685734vqm; Thu, 13 Jul 2023 01:59:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHILjquHKn+RvKq15P/yIMLHv4kIJvXaGCRAYVLSFQuDoaUn/xOnM7nAEi8dX8sbAn4T92R X-Received: by 2002:a17:907:1186:b0:991:e12e:9858 with SMTP id uz6-20020a170907118600b00991e12e9858mr853447ejb.64.1689238765771; Thu, 13 Jul 2023 01:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238765; cv=none; d=google.com; s=arc-20160816; b=kd/QJZcf5O48C1kkfkm0UIdxZyOQghXrArJgfd9WIqqbTV2RWI30T8eYgSVwzhNkAT rKrGusleXYnYAIdZu4I0kvnJMec+BahzoIZWGNP4OdXari7KrnLUw/OiYVsKsJeso2Dh a/zZG+EcNLa5x/pCL0I3gkwqnYRDmm/CVxbAxexH6h5BoGXMEG4c+QkKIcqBNwV6bp0U btWw8T0zBriUVfJZKffxAVM3vRL6vcA3KGCIDYKYahc2xpCbt3fN3olKBzqQco9i2uv5 RoBCX1G0LgY0eXPJzm2ldGwU2VG46YtZRdcre2xKnyww1uCKVKGWCloflvWqsVjU7c+V ZJ9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=gavKeV1HdvfwoYnBdvkbRYPPHwnuLIXrXtk1qaF3WA8=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=d6tG8p84mUnZxltN89vUIZIc8HkvhiXaz71DxOzX587dysXn4zehrIMpjp9EHPujFy JiDDf1si4itaTiRqzuNww2vgTRulzZyZm9+zoNH81s77k3f/lA7wYF/JIzUBoIe7cJkz kfVWL6muRVspolKYz9PBjZsDdZEKgJCE0H0FC81LzNmml6m+qeZ1tFg1dJp0s2f9IKVc FYw1UTRM9PeMsbBz00UCszj398807LlqoLtQ0ug+Ei55fB7b+D47W5Wq25VuyufIbggl fAZ5duT8Zbd/1Q+exErqdClxYxvOaHdhHMsJg2M7pqYu6xn1P4egPqNwngxVdraLnJQS wA6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=l73h7wdE; 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 c21-20020aa7d615000000b0051d7e275e56si6911967edr.272.2023.07.13.01.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:59:25 -0700 (PDT) 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=l73h7wdE; 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 8588D3882175 for ; Thu, 13 Jul 2023 08:55:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8588D3882175 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238504; bh=gavKeV1HdvfwoYnBdvkbRYPPHwnuLIXrXtk1qaF3WA8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=l73h7wdEPZa9H5o1ntOAMyJU/rsgktoTbIPuGqWC4oeAcsZfIzu+Bf7hz8Bf3c31z MroK/liclvrl/+hF3Sh56kfWAxYzZgB8ft8l1KzBeO5rkZGrPQrj+nFcP3YRaRSGrP QjjRIhvMzEYfEUUaJ1maEQMBBqSQ026q9d+3SQlM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id 5AB6C38582B7 for ; Thu, 13 Jul 2023 08:52:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5AB6C38582B7 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs43q0yVd; Thu, 13 Jul 2023 10:52:44 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:44 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 06/14] fortran: Reuse final procedure pointer expression Date: Thu, 13 Jul 2023 10:52:28 +0200 Message-Id: <20230713085236.330222-7-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295227847610896 X-GMAIL-MSGID: 1771295227847610896 Reuse twice the same final procedure pointer expression instead of translating it twice. Final procedure pointer expressions were translated twice, once for the final procedure call, and once for the check for non-nullness (if applicable). gcc/fortran/ChangeLog: * trans.cc (gfc_add_finalizer_call): Move pre and post code for the final procedure pointer expression to the outer block. Reuse the previously evaluated final procedure pointer expression. --- gcc/fortran/trans.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 5c953a07533..3750d4eca82 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1375,7 +1375,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_se final_se; gfc_init_se (&final_se, NULL); get_final_proc_ref (&final_se, final_expr); - gfc_add_block_to_block (&tmp_block, &final_se.pre); + gfc_add_block_to_block (block, &final_se.pre); gfc_se size_se; gfc_init_se (&size_se, NULL); @@ -1395,7 +1395,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_add_block_to_block (&tmp_block, &desc_se.post); gfc_add_block_to_block (&tmp_block, &size_se.post); - gfc_add_block_to_block (&tmp_block, &final_se.post); tmp = gfc_finish_block (&tmp_block); @@ -1404,11 +1403,10 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) tree cond; gfc_se se; - gfc_init_se (&se, NULL); - se.want_pointer = 1; - gfc_conv_expr (&se, final_expr); + tree ptr = gfc_build_addr_expr (NULL_TREE, final_se.expr); + cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, - se.expr, build_int_cst (TREE_TYPE (se.expr), 0)); + ptr, build_int_cst (TREE_TYPE (ptr), 0)); /* For CLASS(*) not only sym->_vtab->_final can be NULL but already sym->_vtab itself. */ @@ -1437,6 +1435,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) } gfc_add_expr_to_block (block, tmp); + gfc_add_block_to_block (block, &final_se.post); return true; } From patchwork Thu Jul 13 08:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1684429vqm; Thu, 13 Jul 2023 01:55:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnGHAWaKi5hmwAaIEVsgg3WoLyF6PjuKRenX4R0JATLEmKbX5XeyWIABhsnU639rChwcG8 X-Received: by 2002:a17:906:8251:b0:992:61c5:dab0 with SMTP id f17-20020a170906825100b0099261c5dab0mr849471ejx.62.1689238543155; Thu, 13 Jul 2023 01:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238543; cv=none; d=google.com; s=arc-20160816; b=brfwh7IX9tQHn4CcztvCYSktTtpD6GDtizUVwaq9OTRutzoJyviawrWUnLtxWYuOO6 pdFTuRH4dV/cB/wTNIAUdzhb3xCIzl9jGE1+j2mSB3ovWr6wq1slwgKCGE+ns5ajzWgR UL7jTHTVl2SMrtY/rAoDKmO5U1Aog2W2vKJtYxJ0svUOEtMscQrBcgrlpT856hiLCGJE C7op7jROcmkGX0LafEEHk5HoHCvKBtdn1KWj6vE6SCwmJoBRkw1dNHEbC4/kPSxN7vQi gkz/mDGRG3PJ0XgvwKs8tgjzsGZTqOPZ0JuJYAj9XwjSwQxo4zHkRNG+vZ2Ay4W8lT/q J+jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=BNG4zJnodo7o828Hze2Fi0n8fW7doYgW4UjAPhpoUHM=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=ATuu0Rn6hHuKHNLkhHzvA7yFOqIYyhLbB/CrmaIOwzI0BlDIO4qRHKHfxh20bSfvuK hnUTKqOkJR8gRwl2r3Wur/TofmW54P7VKAiOczSbqi6ncQ19NOyPaE+UBzxsBiW+Ub3K Ju0ykJ6v6JGf9jiEtXcn5NnsgyWIj0gw97I+mjzoKwd+XEA77Y4WxCxIWH77jhLshNLa x2C+Aqtc61/QGscqFSSnu7xQmRDqt3Mf9ECw3eDARriZnkVuYnRLH53S/k1MsN0SjZhi XdPuI+OBa5uIzS1AriVT18cyN5t8C0wOzWnJgg0aALzesggZEKujYWhgsQKklSlsnkn6 eP1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DhE6tWV4; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id br12-20020a170906d14c00b0098888ba2920si6686407ejb.818.2023.07.13.01.55.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:55:43 -0700 (PDT) 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=DhE6tWV4; 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 F2B00385735D for ; Thu, 13 Jul 2023 08:53:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2B00385735D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238432; bh=BNG4zJnodo7o828Hze2Fi0n8fW7doYgW4UjAPhpoUHM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DhE6tWV40UHXYiHX5DZ1U89y/OoZt2BD+Imc5e/OYt5/gzEkEm+qfi/RUSv/5ADGY xx53L5itF/L4ubvLPRk0abiJ5sgJnGjpLoDUl+ZiSCxogM0Bdl1fXAcg5o/wR8xwvu /1WA70a4ZDdDzGmwjtL7JuccHqsVBIAxhJ056dyE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id C11813858002 for ; Thu, 13 Jul 2023 08:52:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C11813858002 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs44q0yVh; Thu, 13 Jul 2023 10:52:44 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:44 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 07/14] fortran: Push element size expression generation close to its usage Date: Thu, 13 Jul 2023 10:52:29 +0200 Message-Id: <20230713085236.330222-8-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771294994423310865 X-GMAIL-MSGID: 1771294994423310865 gfc_add_finalizer_call creates one expression which is only used by the get_final_proc_ref function. Move the expression generation there. gcc/fortran/ChangeLog: * trans.cc (gfc_add_finalizer_call): Remove local variable elem_size. Pass expression to get_elem_size and move the element size expression generation close to its usage there. (get_elem_size): Add argument expr, remove class_size argument and rebuild it from expr. Remove ts argument and use the type of expr instead. --- gcc/fortran/trans.cc | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 3750d4eca82..e5ad67199e7 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1100,24 +1100,26 @@ get_final_proc_ref (gfc_se *se, gfc_expr *final_wrapper) } -/* Generate the code to obtain the value of the element size whose expression - is passed as argument in CLASS_SIZE. */ +/* Generate the code to obtain the value of the element size of the expression + passed as argument in EXPR. */ static void -get_elem_size (gfc_se *se, gfc_typespec *ts, gfc_expr *class_size) +get_elem_size (gfc_se *se, gfc_expr *expr) { - gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS); + gcc_assert (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS); - if (ts->type == BT_DERIVED) + if (expr->ts.type == BT_DERIVED) { - gcc_assert (!class_size); - se->expr = gfc_typenode_for_spec (ts); + se->expr = gfc_typenode_for_spec (&expr->ts); se->expr = TYPE_SIZE_UNIT (se->expr); se->expr = fold_convert (gfc_array_index_type, se->expr); } else { - gcc_assert (class_size); + gfc_expr *class_size = gfc_copy_expr (expr); + gfc_add_vptr_component (class_size); + gfc_add_size_component (class_size); + gfc_conv_expr (se, class_size); gcc_assert (se->post.head == NULL_TREE); } @@ -1307,7 +1309,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_ref *ref; gfc_expr *expr; gfc_expr *final_expr = NULL; - gfc_expr *elem_size = NULL; bool has_finalizer = false; if (!expr2 || (expr2->ts.type != BT_DERIVED && expr2->ts.type != BT_CLASS)) @@ -1361,10 +1362,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) final_expr = gfc_copy_expr (expr); gfc_add_vptr_component (final_expr); gfc_add_final_component (final_expr); - - elem_size = gfc_copy_expr (expr); - gfc_add_vptr_component (elem_size); - gfc_add_size_component (elem_size); } gcc_assert (final_expr->expr_type == EXPR_VARIABLE); @@ -1379,7 +1376,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_se size_se; gfc_init_se (&size_se, NULL); - get_elem_size (&size_se, &expr->ts, elem_size); + get_elem_size (&size_se, expr); gfc_add_block_to_block (&tmp_block, &size_se.pre); gfc_se desc_se; From patchwork Thu Jul 13 08:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1687432vqm; Thu, 13 Jul 2023 02:02:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlEMPCpIz6jKVbFJOA8LaWwABUUrfXap7Amlz6H9a+PbJD4x2YjcWmvtmyhTjHAUhodC4Lua X-Received: by 2002:aa7:cd4d:0:b0:51e:253e:1e0c with SMTP id v13-20020aa7cd4d000000b0051e253e1e0cmr1140164edw.25.1689238933535; Thu, 13 Jul 2023 02:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238933; cv=none; d=google.com; s=arc-20160816; b=cZBLyfK7BlcNvtHhQSlLkTrXxq4CkC/LKJSSNU26/ACfLgs/+Oby10xBAvQfgJeciD W3JqbRD2lPO3q3P8a9pP5YeR1L11pWp8xhD+n0oylwQ27SVnXXVQsvemr/SE07Jv0i5c /WY9hvUGc/j+FBWJuLW+y5MC7k5RzjSSVmsosWjPKagjNYxWFEjB/3tDTRir+2gfevvr vmBI/qTJEkPaUE/DVlQ+RF3eoKqzgjUWPcGqWpY3uzVQDU/x/OsWNSqashhroCo5fELR hwEAWnSspDivE1YUXJyjSdvseibqHP5MuRxcxi9GokFSknLb9snPJxGdGp/yYZ0enwgm CLyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=Xg7ir7lxlofyTTVIYuoWhc6egUHB/VOEzuxfQbnRzy8=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=lMmXQB2OQbP6WruZNN7LHY6WkSj5jMMvuzHt3a1YFlIn/3IIctWRetH7TN4+uUGgdW 3HZ3Fb6urKWXPbK+Gg/LgITCeM9a35grjFP9/CMojvGTe8SxEHFFZJwmv+LYJvtoISyi 6DxcRYtX9bIViJWG09uAPEfBBZYw8zUyAdfi3sWL4xS7rTl564ix+v8UAu+PSyTQELTF C0tZAqSG+G0QIkeZs5JgWwjYXFPsjGmLpzLy19b4wvjtCWlG5yfufsvB3y0OivYlz0rf E1O82dQclMrkQ4dqtUNqip4enkR1DE8TfTE34cXIIwm/gFytaMztkE8e5IqSYl6fCwvG fuXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="crn25/qS"; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m20-20020aa7c2d4000000b0051df1a7b268si6747059edp.17.2023.07.13.02.02.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:02:13 -0700 (PDT) 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="crn25/qS"; 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 5A3BC389364E for ; Thu, 13 Jul 2023 08:55:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A3BC389364E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238558; bh=Xg7ir7lxlofyTTVIYuoWhc6egUHB/VOEzuxfQbnRzy8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=crn25/qSzqHCD36k2pfVA7NYbz55S8xbJD1tmA/aZtO/JhRiHDXkYKbV6XoEsIlXt fJVA/1JUgGtmQZTP7lEBh6nByZOW4XrNf118PlESEmpIV5VfcXkHoDEWywB8pjHbO/ GobWlW7CzNEf8mzMKxTck0eI/s1j7rgkCItiLEUI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id E67733858020 for ; Thu, 13 Jul 2023 08:52:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E67733858020 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs44q0yVv; Thu, 13 Jul 2023 10:52:44 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:44 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 08/14] fortran: Push final procedure expr gen close to its one usage. Date: Thu, 13 Jul 2023 10:52:30 +0200 Message-Id: <20230713085236.330222-9-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295404220551678 X-GMAIL-MSGID: 1771295404220551678 Final procedure pointer expression is generated in gfc_build_final_call and only used in get_final_proc_ref. Move the generation there. gcc/fortran/ChangeLog: * trans.cc (gfc_add_finalizer_call): Remove local variable final_expr. Pass down expr to get_final_proc_ref and move final procedure expression generation down to its one usage in get_final_proc_ref. (get_final_proc_ref): Add argument expr. Remove argument final_wrapper. Recreate final_wrapper from expr. --- gcc/fortran/trans.cc | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index e5ad67199e7..c6a65c87c5c 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1085,12 +1085,25 @@ gfc_call_free (tree var) } -/* Generate the data reference to the finalization procedure pointer passed as - argument in FINAL_WRAPPER. */ +/* Generate the data reference to the finalization procedure pointer associated + with the expression passed as argument in EXPR. */ static void -get_final_proc_ref (gfc_se *se, gfc_expr *final_wrapper) +get_final_proc_ref (gfc_se *se, gfc_expr *expr) { + gfc_expr *final_wrapper = NULL; + + gcc_assert (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS); + + if (expr->ts.type == BT_DERIVED) + gfc_is_finalizable (expr->ts.u.derived, &final_wrapper); + else + { + final_wrapper = gfc_copy_expr (expr); + gfc_add_vptr_component (final_wrapper); + gfc_add_final_component (final_wrapper); + } + gcc_assert (final_wrapper->expr_type == EXPR_VARIABLE); gfc_conv_expr (se, final_wrapper); @@ -1308,7 +1321,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) tree tmp; gfc_ref *ref; gfc_expr *expr; - gfc_expr *final_expr = NULL; bool has_finalizer = false; if (!expr2 || (expr2->ts.type != BT_DERIVED && expr2->ts.type != BT_CLASS)) @@ -1322,12 +1334,9 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) && expr2->ts.u.derived->attr.defined_assign_comp) return false; - if (expr2->ts.type == BT_DERIVED) - { - gfc_is_finalizable (expr2->ts.u.derived, &final_expr); - if (!final_expr) - return false; - } + if (expr2->ts.type == BT_DERIVED + && !gfc_is_finalizable (expr2->ts.u.derived, NULL)) + return false; /* If we have a class array, we need go back to the class container. */ @@ -1358,20 +1367,14 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) if (!expr2->rank && !expr2->ref && CLASS_DATA (expr2->symtree->n.sym)->as) expr->rank = CLASS_DATA (expr2->symtree->n.sym)->as->rank; - - final_expr = gfc_copy_expr (expr); - gfc_add_vptr_component (final_expr); - gfc_add_final_component (final_expr); } - gcc_assert (final_expr->expr_type == EXPR_VARIABLE); - stmtblock_t tmp_block; gfc_start_block (&tmp_block); gfc_se final_se; gfc_init_se (&final_se, NULL); - get_final_proc_ref (&final_se, final_expr); + get_final_proc_ref (&final_se, expr); gfc_add_block_to_block (block, &final_se.pre); gfc_se size_se; From patchwork Thu Jul 13 08:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1689115vqm; Thu, 13 Jul 2023 02:05:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXbWMRA0c43kCCp+ZZXe4jqK2VKSq6kIyEXqcWBrfcFRUAaSkPLenOBWXMXsO/KRrN6zVW X-Received: by 2002:a17:906:289:b0:993:ff93:cf8f with SMTP id 9-20020a170906028900b00993ff93cf8fmr1024458ejf.8.1689239111240; Thu, 13 Jul 2023 02:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689239111; cv=none; d=google.com; s=arc-20160816; b=GLiUQdiJXY7xsYO1XwMXczcoUVNFN/Y4f6Yap3yJ/CguO6Y8VnNcUkbFvouss62rFm XASjvU2pLxgZi7T3Ql+K2ks8S1PjMUeZz59q/3dKg0Ag0ajkzgBjV3ggc4IbtW9id/Td RcJPfSlZtD0T2W7TO1NE3bQYRmdNG9tbyDjZVFoaqku99NAJ9p5l9SAwlsLkwsj8UZmf uFpyplRaqbFZq+P1sTafZdoVUtJ9fC//VTNfBk6muVc38w4IlhA/8eGh2gEeIwQLNrAX 0XaTNBdOPG1B7EAgMVMrYA+N7J/8H7pQgVITPkyBtZRd+j6Vb8qLmbNrak0wiy1EntcU RXnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=DWS87SdkcrjoBg+SX8sxIUw0kGuSpQze4BEkbtom858=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=jACPN/GkhzJtiF73lXbQHRYVrS1Vpy4x3ZncDH2xSft1j4f9fTx0USjb8hVh4PtMh/ ihzDAYPd/aQ5ZWZIX+Au1cx70m+HpgtfLZ8j5rdnSQ90/bnwWPYEvX77JNnW9KK8T/iw u72XIT7C4bjzSUd3FHlTbL9CstBap5xdlYz+vlYXpFvm32ljZ+jX8vtsczDf1BIB0W4K s18Gawj2ShqN5NFKD8U9KOlEeA5kxCTVYgme3yx7xuxLmIsP38dCvTATSWyBRF4QOJij PCaIJyvm3hQKHA8Jwz9hWMspb5umjSIY1iEs2uXnSIQRjOKRRoiTCCRrDY3nfsvK42U7 5T3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mNRNQLWv; 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 x25-20020a1709064a9900b0098d807ee793si6844561eju.1023.2023.07.13.02.05.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:05:11 -0700 (PDT) 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=mNRNQLWv; 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 381B6393FC39 for ; Thu, 13 Jul 2023 08:56:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 381B6393FC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238616; bh=DWS87SdkcrjoBg+SX8sxIUw0kGuSpQze4BEkbtom858=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mNRNQLWvGjE8oTPJAaHbZhf5QMhR/dChkGQzUrngmQ6bhXN+GGZacq2LGh9oJc3lh hPfEp4JQO2EAQUnhynTpFw9tKyQGepUvWQuw6+MqUrOPJ/mG4AF2F9PFcBpCmQlJ/N qmFI/YoAWBwJFMDkNq3GXnL1iExww2uZQWCbGH5E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id 236493858028 for ; Thu, 13 Jul 2023 08:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 236493858028 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs44q0yW4; Thu, 13 Jul 2023 10:52:44 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:44 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 09/14] fortran: Inline variable definition Date: Thu, 13 Jul 2023 10:52:31 +0200 Message-Id: <20230713085236.330222-10-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295590730734453 X-GMAIL-MSGID: 1771295590730734453 The variable has_finalizer is only used in one place, inline its definition there. gcc/fortran/ChangeLog: * trans.cc (gfc_add_finalizer_call): Inline definition of variable has_finalizer. Merge nested conditions. --- gcc/fortran/trans.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index c6a65c87c5c..99677d37da7 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1321,7 +1321,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) tree tmp; gfc_ref *ref; gfc_expr *expr; - bool has_finalizer = false; if (!expr2 || (expr2->ts.type != BT_DERIVED && expr2->ts.type != BT_CLASS)) return false; @@ -1361,13 +1360,11 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) ref->next = NULL; } - if (expr->ts.type == BT_CLASS) - { - has_finalizer = gfc_is_finalizable (expr->ts.u.derived, NULL); - - if (!expr2->rank && !expr2->ref && CLASS_DATA (expr2->symtree->n.sym)->as) - expr->rank = CLASS_DATA (expr2->symtree->n.sym)->as->rank; - } + if (expr->ts.type == BT_CLASS + && !expr2->rank + && !expr2->ref + && CLASS_DATA (expr2->symtree->n.sym)->as) + expr->rank = CLASS_DATA (expr2->symtree->n.sym)->as->rank; stmtblock_t tmp_block; gfc_start_block (&tmp_block); @@ -1398,7 +1395,8 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) tmp = gfc_finish_block (&tmp_block); - if (expr->ts.type == BT_CLASS && !has_finalizer) + if (expr->ts.type == BT_CLASS + && !gfc_is_finalizable (expr->ts.u.derived, NULL)) { tree cond; gfc_se se; From patchwork Thu Jul 13 08:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1687825vqm; Thu, 13 Jul 2023 02:02:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHnD9EpgiNDOqdnIf3s0IUxFk6urOzu0bX/wqVzZ8M8OftC+WWOqP/4SKbPbN9XNnmME9gW X-Received: by 2002:a17:906:5308:b0:978:9e92:f903 with SMTP id h8-20020a170906530800b009789e92f903mr812583ejo.46.1689238971643; Thu, 13 Jul 2023 02:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238971; cv=none; d=google.com; s=arc-20160816; b=Zq4J/3nhjRCtiIimKzKXaC2r4PPMjQ4nCwUg27JEzPzLbd+xUVUnXjFcsXroxy2q/N L7FV/mJeYbfH2lHLPFEOFlmTkj+/NLsyto6pmVx9Jaxq8WFTDvEbCjnZjgi1osCmLbLL Z8f4e3A8T9zo9QJ9Slewz2aqNcPif/Ri2gyf5G8ZcJrMXUMoFXSkQFKoQR/kYE03lHsv U/eSoxn1Ev3LVTV0N+kYoczWk6eQZbIqtrUKEtdIP/gb9Gza8JxxbysIknuzac1v/RdF LM7pnFJBiy+X2Ds8/uv37rE5v7leD3hmtmry7/RTQMlIUrdWBdMHhYfshNE5W5OFP/hM CbcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=n3AqH/v/T+ZXIu/q4tLQUXthKLPYUOmSptJk5ofp/Og=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=cAvNgMmYlIaf2ea40TnUSJv8INBpcnCDTvMOyazSpR4ydfA5S3AdNK+46g5nvigeaR i78qiP6rt3FlD9nEHfEa0SkOxSAiFtbfgtjR4NN8kKGWafnqsX52hRa0vnz+cLuYNh7l BsCxhH87kjlmknSfxRRViFq1xqcVt6cCPSCRFYBP3q5JZ2kQ7K5wazmJFP4+fjCJTi6c Ua8er+qxpHfMkQmKM5EJeMIdn+SPvoer2qZQoBl/4oR9U6bK+L2KRe690nniocvmdcFw IR1vPFM7bt3L+VgQe/tbCwDwAPHQMhwqDRooh7Lcjk8w0lHJ1NIn8r9BgYVo+TOVjw5v 9OLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vWFl1bfh; 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 d23-20020a170906041700b00982762e2cc4si6717013eja.775.2023.07.13.02.02.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:02:51 -0700 (PDT) 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=vWFl1bfh; 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 7E0393895FF8 for ; Thu, 13 Jul 2023 08:56:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E0393895FF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238569; bh=n3AqH/v/T+ZXIu/q4tLQUXthKLPYUOmSptJk5ofp/Og=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vWFl1bfh7zT74K4utzLGrclID4lkf963Sao4wJOUpQpWRLATCUl341pRuJw1U8WaH cPohmoKEqsLEBeKrM7rJR6W5zW2lK2nUBy24lm0tS+N9c7fPoy1FzuGQctFj82o8eK xwNGO6Ulawjy7NRl8KecxLF3SUYHuUn17AKXPWR4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id 43D6C3858035 for ; Thu, 13 Jul 2023 08:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43D6C3858035 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs44q0yW9; Thu, 13 Jul 2023 10:52:45 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:45 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 10/14] fortran: Remove redundant argument in get_var_descr Date: Thu, 13 Jul 2023 10:52:32 +0200 Message-Id: <20230713085236.330222-11-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295443833280220 X-GMAIL-MSGID: 1771295443833280220 get_var_descr get passed as argument both expr and expr->ts. Remove the type argument which can be retrieved from the other argument. gcc/fortran/ChangeLog: * trans.cc (get_var_descr): Remove argument ts. Use var->ts instead. (gfc_add_finalizer_call): Update caller. --- gcc/fortran/trans.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 99677d37da7..bcf3341fd4b 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1140,11 +1140,10 @@ get_elem_size (gfc_se *se, gfc_expr *expr) /* Generate the data reference (array) descriptor corresponding to the - expression passed as argument in VAR. Use type in TS to pilot code - generation. */ + expression passed as argument in VAR. */ static void -get_var_descr (gfc_se *se, gfc_typespec *ts, gfc_expr *var) +get_var_descr (gfc_se *se, gfc_expr *var) { gfc_se tmp_se; symbol_attribute attr; @@ -1153,7 +1152,7 @@ get_var_descr (gfc_se *se, gfc_typespec *ts, gfc_expr *var) gfc_init_se (&tmp_se, NULL); - if (ts->type == BT_DERIVED) + if (var->ts.type == BT_DERIVED) { tmp_se.want_pointer = 1; if (var->rank) @@ -1381,7 +1380,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_se desc_se; gfc_init_se (&desc_se, NULL); - get_var_descr (&desc_se, &expr->ts, expr); + get_var_descr (&desc_se, expr); gfc_add_block_to_block (&tmp_block, &desc_se.pre); tmp = build_call_expr_loc (input_location, final_se.expr, 3, From patchwork Thu Jul 13 08:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1685510vqm; Thu, 13 Jul 2023 01:58:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlFmouOP5e2nf4YKYDKVx5r7/azHRLmQrgmRcaV2EtQRo8bgg11b1CzC4ZvMjw3OH6iWx81u X-Received: by 2002:a05:6402:31e8:b0:51e:5789:a71d with SMTP id dy8-20020a05640231e800b0051e5789a71dmr1289565edb.12.1689238727619; Thu, 13 Jul 2023 01:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238727; cv=none; d=google.com; s=arc-20160816; b=SO/BGARIz/kfyghcRuafMSmYvoJWknvRulEeSeuJc9XctaBvNmpdxjU6zQbyFNNR+M aZ6z7If1D5hcQAzp1fg8iSVLaqPdxG4Sd7JU+P8U3BBgyutGDpN8/yIc+PIx061/Ka3c ssZ61X6Yd8flbUDU2Ny5RTzNgMDM+Icb1mVPYMiGC+y2xAckGGrsbtJIqcSrURGBnKb9 MD70SGP9mWUd15cNnUTRAj3j/EpKDR098321aEaT6YZCYcned3DXy+YcV0O1xmx+tWWK hSS8B4OPqpO7hy98nXc9IV8WAHzkk3oZTYJAkIaQnj0o4QqXc2xNY4yQA0Uaxdoh6I28 1DLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=U6bDWuyJe0IoEfhYb8xMvcblMtNNEAWLkNyNZUeI2Ik=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=XMRVpCQvQJijqVtcKBnYHjzxNuxU2td1Ks6KG0XTYgNUNHxAOpdyAQYKRdHvBAE2m7 F5wL5Y20/JtiMdvMANnZunEdtJLxPZ0cbWOQD+275MXqJupbH24ycWe2ZM+h796CppJm i2HyLtWoAchXeK6wzdiX/jh/MgoL6ubqB6h1aKF2zJB2QCpJrLV0O7hfR5crYHvOXHg0 jwCG3fkAjWPRHqM4/xymHa8i8gYSj0xwZF00NuwECvahKAhvCTQoLkUNogfJYoHZAouu qCratJUHJeXqAC+CqOHxT8J44+dcK8goWv0kZjUDogc2BsljswexZR6TeM79k6qWHP8V 8NjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qZob5cHI; 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 b10-20020aa7cd0a000000b0051df52adbfasi7383277edw.154.2023.07.13.01.58.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:58:47 -0700 (PDT) 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=qZob5cHI; 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 F033B3882028 for ; Thu, 13 Jul 2023 08:54:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F033B3882028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238492; bh=U6bDWuyJe0IoEfhYb8xMvcblMtNNEAWLkNyNZUeI2Ik=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qZob5cHI38fLfXFqMyWKA6rU8+t32Yx6nWuQweugNtomTJhTu77/aEQb+lX3zr+RN XtHpe7Tk6AfjGx4LKQu9WEfQf8zEPyWztM4qVUA8q3dkeLMHJy+avrEnueDfwiHWT7 ouVcVYc2awvHceSVm4whKx7T06sjkvEF9KikFx2c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id 897243857C51 for ; Thu, 13 Jul 2023 08:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 897243857C51 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs45q0yWB; Thu, 13 Jul 2023 10:52:45 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:45 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 11/14] fortran: Outline virtual table pointer evaluation Date: Thu, 13 Jul 2023 10:52:33 +0200 Message-Id: <20230713085236.330222-12-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295187800104663 X-GMAIL-MSGID: 1771295187800104663 gcc/fortran/ChangeLog: * trans.cc (get_vptr): New function. (gfc_add_finalizer_call): Move virtual table pointer evaluation to get_vptr. --- gcc/fortran/trans.cc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index bcf3341fd4b..731dfb626ab 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1214,6 +1214,23 @@ get_var_descr (gfc_se *se, gfc_expr *var) } +static void +get_vptr (gfc_se *se, gfc_expr *expr) +{ + gfc_expr *vptr_expr = gfc_copy_expr (expr); + gfc_add_vptr_component (vptr_expr); + + gfc_se tmp_se; + gfc_init_se (&tmp_se, NULL); + tmp_se.want_pointer = 1; + gfc_conv_expr (&tmp_se, vptr_expr); + gfc_free_expr (vptr_expr); + + gfc_add_block_to_block (&se->pre, &tmp_se.pre); + gfc_add_block_to_block (&se->post, &tmp_se.post); + se->expr = tmp_se.expr; +} + bool gfc_add_comp_finalizer_call (stmtblock_t *block, tree decl, gfc_component *comp, @@ -1398,7 +1415,6 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) && !gfc_is_finalizable (expr->ts.u.derived, NULL)) { tree cond; - gfc_se se; tree ptr = gfc_build_addr_expr (NULL_TREE, final_se.expr); @@ -1410,19 +1426,14 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) if (UNLIMITED_POLY (expr)) { tree cond2; - gfc_expr *vptr_expr; + gfc_se vptr_se; - vptr_expr = gfc_copy_expr (expr); - gfc_add_vptr_component (vptr_expr); - - gfc_init_se (&se, NULL); - se.want_pointer = 1; - gfc_conv_expr (&se, vptr_expr); - gfc_free_expr (vptr_expr); + gfc_init_se (&vptr_se, NULL); + get_vptr (&vptr_se, expr); cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node, - se.expr, - build_int_cst (TREE_TYPE (se.expr), 0)); + vptr_se.expr, + build_int_cst (TREE_TYPE (vptr_se.expr), 0)); cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR, logical_type_node, cond2, cond); } From patchwork Thu Jul 13 08:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1687101vqm; Thu, 13 Jul 2023 02:01:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhacZeWKROX29yVFB+FrUhqMr1W00rivtsH7put/zkwsd7kwguz82N/LSNKySpgjn6P1GV X-Received: by 2002:a17:906:9b:b0:978:8f29:8c85 with SMTP id 27-20020a170906009b00b009788f298c85mr748687ejc.32.1689238902829; Thu, 13 Jul 2023 02:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238902; cv=none; d=google.com; s=arc-20160816; b=MLSyAvTGoeMOMwycJKHJ6urFe/iTfJssU2qkZ/FgUYVnu3JZOI5N+l3yHcM4kWqz4M XzdHr5c8dmQYT38Dx22H/kIw3P0Cvcjt0DCZP8dpfas1/Mft3ZKH5z+lmCeipv7ozHr8 b5yuXlwwYenuNbzsWzn8CTxz+8AZRRnkfD2ewQ/GkR1nt1prL5d/6cj3JYd8mY9Hy/Yh x5vY2rW90mGSeq9EU4t8TZCgsOT87CQqcnQ+kdbA9BdtJ8knNuNrjLUnoGv0sfTumjkU mzfxxzJMh8DuNtUwtcxvYFrCnMmzIgIyaNtW9zbi0E3ZKRXWBDEgSO6XxrxwSWW/nmNQ 1duw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=2JCzZOcOZjw7wb2lYFy5sUJnZzT9SidF42BCKXmPfPA=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=rJK8MvcQHTOiJvJ0c8usA7veubC0dmOf7B4DY+YAUCXodaP622wCnbxHlwDABgpswW olpEaQrH54YPHA9PxR0RO5ch4yM5dvlSyKfUmJ1lMkViW9a2ewmZOMmN+ObPAGAMecJr WivI1VhV/t6EokZ0tVqbYPrrehBpArP1NTdZcTWnSfjJYRx4EHoqYXrASp4Y+f7s1p5v SjgLxWaAigmdA2KzVv/GD/xT0EQqIUQARVGdqC1KTlKFBD4wU3wjwUTMWlAmDkb+Xg7Z miIL8RfpSiXUzfBSjH3/xTPrc4EAkY/xCLZekQJVZGuptZCO692MLg+FOPxCOs5MU/Pq 6GVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Jl/fo+0J"; 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 f11-20020a170906824b00b0098dfdc3f2e6si6713003ejx.982.2023.07.13.02.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:01:42 -0700 (PDT) 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="Jl/fo+0J"; 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 EFF15388B6B3 for ; Thu, 13 Jul 2023 08:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFF15388B6B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238548; bh=2JCzZOcOZjw7wb2lYFy5sUJnZzT9SidF42BCKXmPfPA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Jl/fo+0J8vR4DoOenAyqk6/hLP/1H4NLLGMz/IQSDRG6j1sGSzx7NZrqnLarIdVGA gIh7UaB6naK48Ri3lJUlKv0HN8PRRVJd+0pzgFUHkjZetLLj0odVNTrQaUstjR+AD4 6weKEUpRzk8FpP77tj8v50kVYJ7J6xNdRLBGPLY8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id CED13385783F for ; Thu, 13 Jul 2023 08:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CED13385783F Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs45q0yWE; Thu, 13 Jul 2023 10:52:45 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:45 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 12/14] fortran: Factor scalar descriptor generation Date: Thu, 13 Jul 2023 10:52:34 +0200 Message-Id: <20230713085236.330222-13-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295371961202012 X-GMAIL-MSGID: 1771295371961202012 The same scalar descriptor generation code is present twice, in the case of derived type entities, and in the case of polymorphic non-coarray entities. Factor it in preparation for a future third case that will also need the same code for scalar descriptor generation. gcc/fortran/ChangeLog: * trans.cc (get_var_descr): Factor scalar descriptor generation. --- gcc/fortran/trans.cc | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 731dfb626ab..69e9329c9cb 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1146,7 +1146,6 @@ static void get_var_descr (gfc_se *se, gfc_expr *var) { gfc_se tmp_se; - symbol_attribute attr; gcc_assert (var); @@ -1164,13 +1163,6 @@ get_var_descr (gfc_se *se, gfc_expr *var) { gfc_conv_expr (&tmp_se, var); // gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); - - /* No copy back needed, hence set attr's allocatable/pointer - to zero. */ - gfc_clear_attr (&attr); - tmp_se.expr = gfc_conv_scalar_to_descriptor (&tmp_se, tmp_se.expr, - attr); - gcc_assert (tmp_se.post.head == NULL_TREE); } } else @@ -1191,20 +1183,25 @@ get_var_descr (gfc_se *se, gfc_expr *var) gfc_add_data_component (array_expr); gfc_conv_expr (&tmp_se, array_expr); gcc_assert (tmp_se.post.head == NULL_TREE); - - if (!gfc_is_coarray (array_expr)) - { - /* No copy back needed, hence set attr's allocatable/pointer - to zero. */ - gfc_clear_attr (&attr); - tmp_se.expr = gfc_conv_scalar_to_descriptor (&tmp_se, tmp_se.expr, - attr); - } - gcc_assert (tmp_se.post.head == NULL_TREE); } gfc_free_expr (array_expr); } + if (var->rank == 0) + { + if (var->ts.type == BT_DERIVED + || !gfc_is_coarray (var)) + { + /* No copy back needed, hence set attr's allocatable/pointer + to zero. */ + symbol_attribute attr; + gfc_clear_attr (&attr); + tmp_se.expr = gfc_conv_scalar_to_descriptor (&tmp_se, tmp_se.expr, + attr); + } + gcc_assert (tmp_se.post.head == NULL_TREE); + } + if (!POINTER_TYPE_P (TREE_TYPE (tmp_se.expr))) tmp_se.expr = gfc_build_addr_expr (NULL, tmp_se.expr); From patchwork Thu Jul 13 08:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1689999vqm; Thu, 13 Jul 2023 02:07:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlECqzjJG0Q86o2xREqMdPvmW5LsefYm9/ensAbZYGBSYbZc+6ClQwv+/iVXRAcnmWS1H0XN X-Received: by 2002:a17:907:2d92:b0:993:e512:cb59 with SMTP id gt18-20020a1709072d9200b00993e512cb59mr992082ejc.9.1689239221054; Thu, 13 Jul 2023 02:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689239221; cv=none; d=google.com; s=arc-20160816; b=Jq0tUImlbClDK5Iyj6X43S9BlxvSGvAzauilar7llqJVZ+0rj6YrKnRnzPLCioI8aX F4Offrenrj02g+ONX2b7YhoiF3WZwQl+f7tzsUGXNV08YAjyHydgqjKSFUmHBICMMw9x 0Q9UOGQC+FDUtFLdsBJ9t0RCjBjxS9vgymkmlvX/VKrtmdVKquG3w4ERRSPxYIj6Nfzg Z5jbhGe01Y15BFweadMB8M5j6bfvDmXbSEo4IDRoAM8NHSjpRqHvWkflnvAnIubbQqeJ G7ut8ApiQo4Xf0DbF7qLPirSwp9xlPVLx+DYCdtF0IYJn99998OuSlBYx2de1hVuzxjk gUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=HtuvCzVObHdBdYeu1Jd6san33AasMzsP7XCIx9SdWXU=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=vvMY32vOktd3/Tm2ox69yghKD3UXX2lWqQvqo2Ftvno3v3sMMwWHbRUjZAvWG9lFSk wd47UR2kPMRmb5mPv3s0y34PwNioAPynPu9s5gOhK9Y/ooXxq9h7rKKFRE+w3EowFjHI kD7LKttdcsmPuDhz6tJQkH6UGnKpmDRK8N42Bk8Ud1mNlOGLX3mwGXAwIXyeIlE0aeWC +08q+zKyF/J7CSH9qQbtZg+lN0KbGbX7cSvY3IivRsoeupc95h1z0q1WFQLA88kxsTHW QTY/hNonu0HuOuCg0ayDLPGeRh+BK+HNh4b587GvdYgPtgVrOxwkNcpVrmGD+q3k44Db idaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Od9KNy/k"; 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 c8-20020a170906170800b009930e13beb8si6523517eje.952.2023.07.13.02.07.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:07:01 -0700 (PDT) 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="Od9KNy/k"; 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 9E334395200B for ; Thu, 13 Jul 2023 08:57:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E334395200B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238673; bh=HtuvCzVObHdBdYeu1Jd6san33AasMzsP7XCIx9SdWXU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Od9KNy/keNl1S/6nQMfPSP5qHMgzYqWvnatfRQfYX6kyJ6g3qCB7x5fQQ6+l/A3rT 1F6sdQsqZOgR2kFNDNHVXSh1g4DBnCk7XO+sCBpEq0/EkHbzAnIve0vTB4Z9OcUluV 1FiFwfrqA2Fv+OusVJFECpRIks//2tdk+cfSaRkQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id 1709E385771B for ; Thu, 13 Jul 2023 08:52:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1709E385771B Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs45q0yWG; Thu, 13 Jul 2023 10:52:45 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:45 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 13/14] fortran: Use pre-evaluated class container if available [PR110618] Date: Thu, 13 Jul 2023 10:52:35 +0200 Message-Id: <20230713085236.330222-14-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295705496602874 X-GMAIL-MSGID: 1771295705496602874 Add the possibility to provide a pre-evaluated class container argument to gfc_add_finalizer to avoid repeatedly evaluating data reference expressions in the generated code. PR fortran/110618 gcc/fortran/ChangeLog: * trans.h (gfc_add_finalizer_call): Add class container argument. * trans.cc (gfc_add_finalizer_call): Ditto. Pass down new argument to get_final_proc_ref, get_elem_size, get_var_desc, and get_vptr. (get_elem_size): Add class container argument. Use provided class container if it's available. (get_var_descr): Same. (get_vptr): Same. (get_final_proc_ref): Same. Add boolean telling the class container argument is used. Set it. Don't try to use final_wrapper if class container argument was used. --- gcc/fortran/trans.cc | 61 +++++++++++++++++++++++++++++--------------- gcc/fortran/trans.h | 2 +- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 69e9329c9cb..18965b9cbd2 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1089,14 +1089,20 @@ gfc_call_free (tree var) with the expression passed as argument in EXPR. */ static void -get_final_proc_ref (gfc_se *se, gfc_expr *expr) +get_final_proc_ref (gfc_se *se, gfc_expr *expr, tree class_container) { gfc_expr *final_wrapper = NULL; gcc_assert (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS); + bool using_class_container = false; if (expr->ts.type == BT_DERIVED) gfc_is_finalizable (expr->ts.u.derived, &final_wrapper); + else if (class_container) + { + using_class_container = true; + se->expr = gfc_class_vtab_final_get (class_container); + } else { final_wrapper = gfc_copy_expr (expr); @@ -1104,9 +1110,12 @@ get_final_proc_ref (gfc_se *se, gfc_expr *expr) gfc_add_final_component (final_wrapper); } - gcc_assert (final_wrapper->expr_type == EXPR_VARIABLE); + if (!using_class_container) + { + gcc_assert (final_wrapper->expr_type == EXPR_VARIABLE); - gfc_conv_expr (se, final_wrapper); + gfc_conv_expr (se, final_wrapper); + } if (POINTER_TYPE_P (TREE_TYPE (se->expr))) se->expr = build_fold_indirect_ref_loc (input_location, se->expr); @@ -1117,7 +1126,7 @@ get_final_proc_ref (gfc_se *se, gfc_expr *expr) passed as argument in EXPR. */ static void -get_elem_size (gfc_se *se, gfc_expr *expr) +get_elem_size (gfc_se *se, gfc_expr *expr, tree class_container) { gcc_assert (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS); @@ -1127,6 +1136,8 @@ get_elem_size (gfc_se *se, gfc_expr *expr) se->expr = TYPE_SIZE_UNIT (se->expr); se->expr = fold_convert (gfc_array_index_type, se->expr); } + else if (class_container) + se->expr = gfc_class_vtab_size_get (class_container); else { gfc_expr *class_size = gfc_copy_expr (expr); @@ -1143,7 +1154,7 @@ get_elem_size (gfc_se *se, gfc_expr *expr) expression passed as argument in VAR. */ static void -get_var_descr (gfc_se *se, gfc_expr *var) +get_var_descr (gfc_se *se, gfc_expr *var, tree class_container) { gfc_se tmp_se; @@ -1165,6 +1176,8 @@ get_var_descr (gfc_se *se, gfc_expr *var) // gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); } } + else if (class_container) + tmp_se.expr = gfc_class_data_get (class_container); else { gfc_expr *array_expr; @@ -1212,20 +1225,25 @@ get_var_descr (gfc_se *se, gfc_expr *var) static void -get_vptr (gfc_se *se, gfc_expr *expr) +get_vptr (gfc_se *se, gfc_expr *expr, tree class_container) { - gfc_expr *vptr_expr = gfc_copy_expr (expr); - gfc_add_vptr_component (vptr_expr); + if (class_container) + se->expr = gfc_class_vptr_get (class_container); + else + { + gfc_expr *vptr_expr = gfc_copy_expr (expr); + gfc_add_vptr_component (vptr_expr); - gfc_se tmp_se; - gfc_init_se (&tmp_se, NULL); - tmp_se.want_pointer = 1; - gfc_conv_expr (&tmp_se, vptr_expr); - gfc_free_expr (vptr_expr); + gfc_se tmp_se; + gfc_init_se (&tmp_se, NULL); + tmp_se.want_pointer = 1; + gfc_conv_expr (&tmp_se, vptr_expr); + gfc_free_expr (vptr_expr); - gfc_add_block_to_block (&se->pre, &tmp_se.pre); - gfc_add_block_to_block (&se->post, &tmp_se.post); - se->expr = tmp_se.expr; + gfc_add_block_to_block (&se->pre, &tmp_se.pre); + gfc_add_block_to_block (&se->post, &tmp_se.post); + se->expr = tmp_se.expr; + } } @@ -1329,7 +1347,8 @@ gfc_add_comp_finalizer_call (stmtblock_t *block, tree decl, gfc_component *comp, true when a finalizer call has been inserted. */ bool -gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) +gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2, + tree class_container) { tree tmp; gfc_ref *ref; @@ -1384,17 +1403,17 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_se final_se; gfc_init_se (&final_se, NULL); - get_final_proc_ref (&final_se, expr); + get_final_proc_ref (&final_se, expr, class_container); gfc_add_block_to_block (block, &final_se.pre); gfc_se size_se; gfc_init_se (&size_se, NULL); - get_elem_size (&size_se, expr); + get_elem_size (&size_se, expr, class_container); gfc_add_block_to_block (&tmp_block, &size_se.pre); gfc_se desc_se; gfc_init_se (&desc_se, NULL); - get_var_descr (&desc_se, expr); + get_var_descr (&desc_se, expr, class_container); gfc_add_block_to_block (&tmp_block, &desc_se.pre); tmp = build_call_expr_loc (input_location, final_se.expr, 3, @@ -1426,7 +1445,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2) gfc_se vptr_se; gfc_init_se (&vptr_se, NULL); - get_vptr (&vptr_se, expr); + get_vptr (&vptr_se, expr, class_container); cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node, vptr_se.expr, diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 7b41e8912b4..be9ccbc3d29 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -457,7 +457,7 @@ tree gfc_get_class_from_gfc_expr (gfc_expr *); tree gfc_get_class_from_expr (tree); tree gfc_get_vptr_from_expr (tree); tree gfc_copy_class_to_class (tree, tree, tree, bool); -bool gfc_add_finalizer_call (stmtblock_t *, gfc_expr *); +bool gfc_add_finalizer_call (stmtblock_t *, gfc_expr *, tree = NULL_TREE); bool gfc_add_comp_finalizer_call (stmtblock_t *, tree, gfc_component *, bool); void gfc_finalize_tree_expr (gfc_se *, gfc_symbol *, symbol_attribute, int); bool gfc_assignment_finalizer_call (gfc_se *, gfc_expr *, bool); From patchwork Thu Jul 13 08:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 119695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1690640vqm; Thu, 13 Jul 2023 02:08:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFx0S27uB+gycq8Flza/FiTicGML8VVzyQdnfedB6Ybu1iX37tVDCqiWgYe7Nyo5TwzclRi X-Received: by 2002:a17:907:3fa0:b0:986:38ab:ef99 with SMTP id hr32-20020a1709073fa000b0098638abef99mr6808304ejc.9.1689239298385; Thu, 13 Jul 2023 02:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689239298; cv=none; d=google.com; s=arc-20160816; b=xbD7vrwOy+61V+cNUREH/XCgpRdrTKYg5/n+HjriZ5bSb8VolUWlQuDXmZqTQX1L0l bAGVQSBSlw5XDMSsCqAhRyU82aXxE4A04Yy9HSQ4pX+x5E9ZHYbb58MoBvmDC20JPdu/ A01JueYdaa8Q1U6nq1joWkA+JZMBsZW+eMzjolV1Fl48Hy5zfswxnBXH52KPsAwvMvEs YtJBaBHbhFex8on6ZcQqQCb29GfXFDfRHtuzmAYQRqC2ngt6wsh6Ets4tphDxjG8B2W6 0BwFP3EcvSVmzCP09fgMd1oyZJRBDMWEhOeovySG/GQXuxL9uf+1kRF6Q8hNVxOLE4yI 500Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=d5Zv/wV77niuEQ8Y4n/HzaRWpkwq6r5GWs3aTENHrpk=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=EkbKpmNsTnJcFG/KuDXubgc1HMTtN3Pc7IkyiU9MPXswaFN6Z3vlTynl2OJ2ZbrVbF InlSKjc9/plaUNhH058FsAzX+3ntedVF/cCsi8lC1+AMd0VzhJTNXtOdFrSvla+v4z1o Rerbs8Ucjj9amZ2f0yXuPcu1MFEY9m1WswtUoBfv2GsIfJmBS6Fna9blD6gaCGwh3sHi tDejYGwCnucPpztBVryJF/6xYLpsU2f46MUeXr19qcf5Yx7zNYt2/bEmaQ0Rb6EypaDC j7b3ga9IwHyWTAXDN1UFwdcul519AVgyXIYUGPZeSrdaPW5l0sHmEa0EIqYAcAMd2HAe F+EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XKlMrMwX; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id rv6-20020a17090710c600b009933205fdb5si6579350ejb.141.2023.07.13.02.08.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:08:18 -0700 (PDT) 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=XKlMrMwX; 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 A588E3852AD8 for ; Thu, 13 Jul 2023 08:58:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A588E3852AD8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238730; bh=d5Zv/wV77niuEQ8Y4n/HzaRWpkwq6r5GWs3aTENHrpk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XKlMrMwXxjDZiuqYKaN2r0QaJRqS9TBWsYpjOI/MJZpB4pSdvMp2USa4natYL7R48 O7SZpjnEk2CpjElSBSdSY0DrhaeG+lZWlELD0De2duHWMiR1N/OKz0WIqdBCPJvyli Pilakf9qwfW774lASV24P3gtb7P7wCHwADGV5Cag= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id 3F7373857722 for ; Thu, 13 Jul 2023 08:52:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F7373857722 Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs45q0yWP; Thu, 13 Jul 2023 10:52:45 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:45 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 14/14] fortran: Pass pre-calculated class container argument [pr110618] Date: Thu, 13 Jul 2023 10:52:36 +0200 Message-Id: <20230713085236.330222-15-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> References: <20230713085236.330222-1-mikael@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295786549584701 X-GMAIL-MSGID: 1771295786549584701 Pass already evaluated class container argument from gfc_conv_procedure_call down to gfc_add_finalizer_call through gfc_deallocate_scalar_with_status and gfc_deallocate_with_status, to avoid repeatedly evaluating the same data reference expressions in the generated code. PR fortran/110618 gcc/fortran/ChangeLog: * trans.h (gfc_deallocate_with_status): Add class container argument. (gfc_deallocate_scalar_with_status): Ditto. * trans.cc (gfc_deallocate_with_status): Add class container argument and pass it down to gfc_add_finalize_call. (gfc_deallocate_scalar_with_status): Same. * trans-array.cc (structure_alloc_comps): Update caller. * trans-stmt.cc (gfc_trans_deallocate): Ditto. * trans-expr.cc (gfc_conv_procedure_call): Ditto. Pass pre-evaluated class container argument if it's available. gcc/testsuite/ChangeLog: * gfortran.dg/intent_out_22.f90: New test. --- gcc/fortran/trans-array.cc | 2 +- gcc/fortran/trans-expr.cc | 7 ++-- gcc/fortran/trans-stmt.cc | 3 +- gcc/fortran/trans.cc | 11 +++--- gcc/fortran/trans.h | 7 ++-- gcc/testsuite/gfortran.dg/intent_out_22.f90 | 37 +++++++++++++++++++++ 6 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/intent_out_22.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 1c2af55d436..951cecfa5d5 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9472,7 +9472,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tree dest, tmp = gfc_deallocate_with_status (comp, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, true, - NULL, caf_dereg_mode, + NULL, caf_dereg_mode, NULL_TREE, add_when_allocated, caf_token); gfc_add_expr_to_block (&tmpblock, tmp); diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index dbb04f8c434..8258543b456 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -6706,9 +6706,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, if (e->ts.type == BT_CLASS) ptr = gfc_class_data_get (ptr); + tree cls = parmse.class_container; tmp = gfc_deallocate_scalar_with_status (ptr, NULL_TREE, NULL_TREE, true, - e, e->ts); + e, e->ts, cls); gfc_add_expr_to_block (&block, tmp); tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, ptr, @@ -6900,10 +6901,12 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, ptr = parmse.expr; ptr = gfc_class_data_get (ptr); + tree cls = parmse.class_container; tmp = gfc_deallocate_with_status (ptr, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, true, e, - GFC_CAF_COARRAY_NOCOARRAY); + GFC_CAF_COARRAY_NOCOARRAY, + cls); gfc_add_expr_to_block (&block, tmp); tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, ptr, diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 7e768343a57..93f36bfb955 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -7462,7 +7462,8 @@ gfc_trans_deallocate (gfc_code *code) { tmp = gfc_deallocate_scalar_with_status (se.expr, pstat, label_finish, false, al->expr, - al->expr->ts, is_coarray); + al->expr->ts, NULL_TREE, + is_coarray); gfc_add_expr_to_block (&se.pre, tmp); /* Set to zero after deallocation. */ diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 18965b9cbd2..569fad45031 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1777,8 +1777,8 @@ tree gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen, tree label_finish, bool can_fail, gfc_expr* expr, - int coarray_dealloc_mode, tree add_when_allocated, - tree caf_token) + int coarray_dealloc_mode, tree class_container, + tree add_when_allocated, tree caf_token) { stmtblock_t null, non_null; tree cond, tmp, error; @@ -1872,7 +1872,7 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, gfc_start_block (&non_null); if (add_when_allocated) gfc_add_expr_to_block (&non_null, add_when_allocated); - gfc_add_finalizer_call (&non_null, expr); + gfc_add_finalizer_call (&non_null, expr, class_container); if (coarray_dealloc_mode == GFC_CAF_COARRAY_NOCOARRAY || flag_coarray != GFC_FCOARRAY_LIB) { @@ -1977,7 +1977,8 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree gfc_deallocate_scalar_with_status (tree pointer, tree status, tree label_finish, bool can_fail, gfc_expr* expr, - gfc_typespec ts, bool coarray) + gfc_typespec ts, tree class_container, + bool coarray) { stmtblock_t null, non_null; tree cond, tmp, error; @@ -2030,7 +2031,7 @@ gfc_deallocate_scalar_with_status (tree pointer, tree status, tree label_finish, gfc_start_block (&non_null); /* Free allocatable components. */ - finalizable = gfc_add_finalizer_call (&non_null, expr); + finalizable = gfc_add_finalizer_call (&non_null, expr, class_container); if (!finalizable && ts.type == BT_DERIVED && ts.u.derived->attr.alloc_comp) { int caf_mode = coarray diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index be9ccbc3d29..109d7647235 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -771,10 +771,11 @@ void gfc_allocate_using_malloc (stmtblock_t *, tree, tree, tree); /* Generate code to deallocate an array. */ tree gfc_deallocate_with_status (tree, tree, tree, tree, tree, bool, - gfc_expr *, int, tree a = NULL_TREE, - tree c = NULL_TREE); + gfc_expr *, int, tree = NULL_TREE, + tree a = NULL_TREE, tree c = NULL_TREE); tree gfc_deallocate_scalar_with_status (tree, tree, tree, bool, gfc_expr*, - gfc_typespec, bool c = false); + gfc_typespec, tree = NULL_TREE, + bool c = false); /* Generate code to call realloc(). */ tree gfc_call_realloc (stmtblock_t *, tree, tree); diff --git a/gcc/testsuite/gfortran.dg/intent_out_22.f90 b/gcc/testsuite/gfortran.dg/intent_out_22.f90 new file mode 100644 index 00000000000..a38afccf0e5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/intent_out_22.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! +! PR fortran/110618 +! Check that if a data reference is passed as actual argument whose dummy +! has INTENT(OUT) attribute, any other argument depending on the +! same data reference is evaluated before the data reference deallocation. + +program p + implicit none + type t + integer :: i + end type t + type u + class(t), allocatable :: ta(:) + end type u + type(u), allocatable :: c(:) + class(t), allocatable :: d(:) + allocate(c, source = [u([t(1), t(3)]), u([t(4), t(9)])]) + allocate(d, source = [t(1), t(5)]) + call bar ( & + allocated(c(d(1)%i)%ta), & + d, & + c(d(1)%i)%ta, & + allocated (c(d(1)%i)%ta) & + ) + if (allocated (c(1)%ta)) stop 11 + if (.not. allocated (c(2)%ta)) stop 11 +contains + subroutine bar (alloc, x, y, alloc2) + logical :: alloc, alloc2 + class(t), allocatable, intent(out) :: x(:) + class(t), allocatable, intent(out) :: y(:) + if (allocated (x)) stop 1 + if (.not. alloc) stop 2 + if (.not. alloc2) stop 3 + end subroutine bar +end