From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45822 invoked by alias); 6 Nov 2015 20:28:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 45811 invoked by uid 89); 6 Nov 2015 20:28:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 Nov 2015 20:28:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 23049A2C01; Fri, 6 Nov 2015 20:28:47 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA6KSigN009922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 6 Nov 2015 15:28:46 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tA6KShhW002195; Fri, 6 Nov 2015 21:28:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tA6KSfig002194; Fri, 6 Nov 2015 21:28:41 +0100 Date: Fri, 06 Nov 2015 20:28:00 -0000 From: Jakub Jelinek To: James Norris Cc: Thomas Schwinge , GCC Patches Subject: Re: [OpenACC] declare directive Message-ID: <20151106202841.GL5675@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <562FDBF8.1040105@mentor.com> <5638E164.5010207@codesourcery.com> <87611h1zi7.fsf@kepler.schwinge.homeip.net> <563CD07A.3000404@codesourcery.com> <20151106190352.GG5675@tucnak.redhat.com> <20151106192255.GH5675@tucnak.redhat.com> <563D0B03.30406@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <563D0B03.30406@codesourcery.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00728.txt.bz2 On Fri, Nov 06, 2015 at 02:18:11PM -0600, James Norris wrote: > On 11/06/2015 01:22 PM, Jakub Jelinek wrote: > >On Fri, Nov 06, 2015 at 08:03:52PM +0100, Jakub Jelinek wrote: > >>What exactly do you want to achieve? Why do you record it > >>in gimplify_omp_ctx, but then only look at it in gimplify_body? > >>The way you abuse gimplify_omp_ctx for that is just too ugly. > >>All the gimplification code expects that when you enter some OpenMP/OpenACC > >>construct, you create new context if it needs one, then process the body > >>of the construct, then pop it up. The declare_returns stuff > >>violates all of this. Do you want to enqueue all the statements > >>at the end of the body? Then just stick it into some gimple_seq > >>outside of the gimplify_omp_ctx, and process in there. Or if you > >>want to process it when leaving some construct, arrange for that. > >If the unmap operation is supposed to sit where the corresponding variable > >goes out of scope, supposedly you would need to find out in which bind > >(gimplify_ctx (not omp!)) the variable is declared and arrange for the > >statement to be added as a cleanup of that region. > >If you queue everything to the end of function, I'm afraid with e.g. > >void foo (void) > >{ > > { > > char buf[2048]; > > #acc declare whatever(buf) > > // ... > > } > > { > > char buf2[2048]; > > #acc declare whatever(buf2) > > // ... > > } > >} > >both vars will be assigned overlapping ranges and you might run into > >trouble trying to map buf2 while buf is still mapped. > > > > Jakub > > Good point. Perhaps what would work is stick the "exit" clauses you need for automatic vars in the function inside of some pointer map / hash table / whatever, and then in gimplify_bind_expr in the /* Add clobbers for all variables that go out of scope. */ if if flag_openacc && the pointer_map /hash table has any entries look up each variable in there and collect the clauses from those vars that go out of scope, after the loop if any were collected construct the statement you need prepend it to cleanup (so that it works before restoring VLA memory and before the clobber stmts). Jakub