From patchwork Thu Sep 20 19:29:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_K=C3=B6nig?= X-Patchwork-Id: 972687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-486089-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tkoenig.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cQAAA3lo"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=tkoenig.net header.i=@tkoenig.net header.b="NOpqgeYq"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42GRdb2GmTz9sBq for ; Fri, 21 Sep 2018 05:30:10 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=sVh6z/9VTNL323WZ 8QoPGL2zVtGUT6v3Cxbq2yeW1kEgMzuuZ9uliw7Ix8gCtnYzL9h9WUm7llHwWvm6 73FY7O0XtVIzi9eJclUc6CfwQjg4i3+jVvcqHQyQ260JAkL0PFHWY/bAf7DBtFaH bsJLC5YsxuigxNhYKDIRLx7AE8g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=QRLMpeLPSkmys+bN+Q8qUa Wt6d4=; b=cQAAA3log0zpDnooioljfksOLPtfl6VxMXg+j5L+UDCnTmOEoRMPvl PYR1yQ42shUYvubpcftmG44k0t4CDEq1Y44L2nII17jA4/bHtbGl8UzeCa3E9yO3 7iKs0Soi2WbRC4pfgAP/5+oocHNKIaPMBsgiFHRAPSuWw2lQwN76Y= Received: (qmail 118867 invoked by alias); 20 Sep 2018 19:29:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 118742 invoked by uid 89); 20 Sep 2018 19:29:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=264423, sk:gfc_fin, Arbeitskopie, bt_class X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Sep 2018 19:29:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1537471778; s=strato-dkim-0002; d=tkoenig.net; h=Date:Message-ID:Subject:From:To:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=UtH5mV1wQt4rV7y3yGwEnAKRi2P/eRQHaARKwfrLQP0=; b=NOpqgeYq/w2QsuFXTwIXQbKC3/+VVFNwTQMUy7HYdA2owi0cwk/7LryF4mLtnaG4nq bkzLjS3zArZmz/uFK05PGJi+xLrZ1BrWL47Y9pgXCqG74VdG6TSpLbyo6mUxBVKoCXmB LULmXtykLcd123k38opiOXuPE4QX+5xtqxQQ+iPRFPJaZxHsnLyGWqHvKq0FLn7a6Cad lt5m4fRPbWhhdnAhvwLiEbqa0vv69/VrzVNip2r0IAYLMU46Isj8Ps5oKa0PMiEa/X5P h6htMskcd/n/wolYgaLa/RfLCMzMBs00uxWb/5WJkohB98UE5z8xzFZk+U4G5p43QbGF oMgg== Received: from [192.168.178.68] by smtp.strato.de (RZmta 44.1 DYNA|AUTH) with ESMTPSA id i05aecu8KJTbPHs (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 20 Sep 2018 21:29:37 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: =?utf-8?q?Thomas_K=C3=B6nig?= Subject: [patch, rfc] Clobber scalar intent(out) variables on entry Message-ID: Date: Thu, 20 Sep 2018 21:29:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Hi, the patch below tries to clobber scalar intent(out) arguments on procedure entry. } With this patch, module x contains subroutine foo(a) real, intent(out) :: a a = 21. a = a + 22. end subroutine foo end module x generates, with -fdump-tree-original foo (real(kind=4) & restrict a) { *a = {CLOBBER}; *a = 2.1e+1; *a = *a + 2.2e+1; } Is this the right way to proceed? (The if statement is not yet correct, so this version causes regressions, that would have to be adjusted). Regards Thomas Index: trans-decl.c =================================================================== --- trans-decl.c (Revision 264423) +++ trans-decl.c (Arbeitskopie) @@ -4143,6 +4143,19 @@ init_intent_out_dt (gfc_symbol * proc_sym, gfc_wra gfc_add_expr_to_block (&init, tmp); } + else if (f->sym->attr.dummy && !f->sym->attr.dimension + && f->sym->attr.intent == INTENT_OUT + && !f->sym->attr.codimension && !f->sym->attr.allocatable + && (f->sym->ts.type != BT_CLASS + || (!CLASS_DATA (f->sym)->attr.dimension + && !(CLASS_DATA (f->sym)->attr.codimension + && CLASS_DATA (f->sym)->attr.allocatable)))) + { + tree t1, t2; + t1 = build_fold_indirect_ref_loc (input_location, f->sym->backend_decl); + t2 = build_clobber (TREE_TYPE (t1)); + gfc_add_modify (&init, t1, t2); + } gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);