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); }