From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96211 invoked by alias); 3 Nov 2015 04:29:56 -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 96143 invoked by uid 89); 3 Nov 2015 04:29:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 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; Tue, 03 Nov 2015 04:29:53 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 68AD58535A; Tue, 3 Nov 2015 04:29:52 +0000 (UTC) Received: from freie.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA34Tn6B011623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Nov 2015 23:29:51 -0500 Received: from livre.home (livre.home [172.31.160.2]) by freie.home (8.15.2/8.15.2) with ESMTP id tA34TfOt004311; Tue, 3 Nov 2015 02:29:42 -0200 From: Alexandre Oliva To: Jeff Law Cc: Richard Biener , =?utf-8?Q?Uro=C5=A1?= Bizjak , Alan Lawrence , James Greenhalgh , "H.J. Lu" , Segher Boessenkool , GCC Patches , Christophe Lyon , David Edelsohn , Eric Botcazou Subject: Re: [PR67891] drop is_gimple_reg test from set_parm_rtl References: <20150810082355.GA31149@arm.com> <55C8BFC3.3030603@redhat.com> <55E72D4C.40705@arm.com> <55FC3171.7040509@arm.com> <56382653.4060605@redhat.com> Date: Tue, 03 Nov 2015 04:29:00 -0000 In-Reply-To: <56382653.4060605@redhat.com> (Jeff Law's message of "Mon, 2 Nov 2015 20:13:23 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2015-11/txt/msg00155.txt.bz2 On Nov 3, 2015, Jeff Law wrote: > On 11/02/2015 06:11 PM, Alexandre Oliva wrote: >> On Oct 14, 2015, Richard Biener wrote: >>> It looks ok to me but lacks a comment in mark_addressable_1 why we >>> do this queueing when currently expanding to RTL. >> >>>> +/* Mark X as addressable or queue it up if called during expand. */ >>>> + >>>> +static void >>>> +mark_addressable_1 (tree x) >> >> How about this: >> >> /* Mark X as addressable or queue it up if called during expand. We >> don't want to apply it immediately during expand because decls are >> made addressable at that point due to RTL-only concerns, such as >> uses of memcpy for block moves, and TREE_ADDRESSABLE changes >> is_gimple_reg, which might make it seem like a variable that used >> to be a gimple_reg shouldn't have been an SSA name. So we queue up >> this flag setting and only apply it when we're done with GIMPLE and >> only RTL issues matter. */ > Sounds good. Thanks, here's the patch as just installed. for gcc/ChangeLog * gimple-expr.c: Include hash-set.h and rtl.h. (mark_addressable_queue): New var. (mark_addressable): Factor actual marking into... (mark_addressable_1): ... this. Queue it up during expand. (mark_addressable_2): New. (flush_mark_addressable_queue): New. * gimple-expr.h (flush_mark_addressable_queue): Declare. * cfgexpand.c: Include gimple-expr.h. (pass_expand::execute): Flush mark_addressable queue. --- gcc/cfgexpand.c | 3 +++ gcc/gimple-expr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++-- gcc/gimple-expr.h | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index b59ea02..bfbc958 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "internal-fn.h" #include "tree-eh.h" #include "gimple-iterator.h" +#include "gimple-expr.h" #include "gimple-walk.h" #include "tree-cfg.h" #include "tree-dfa.h" @@ -6368,6 +6369,8 @@ pass_expand::execute (function *fun) /* We're done expanding trees to RTL. */ currently_expanding_to_rtl = 0; + flush_mark_addressable_queue (); + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (fun)->next_bb, EXIT_BLOCK_PTR_FOR_FN (fun), next_bb) { diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index 44749b81..f5f9e87 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see #include "gimplify.h" #include "stor-layout.h" #include "demangle.h" +#include "hash-set.h" +#include "rtl.h" /* ----- Type related ----- */ @@ -817,6 +819,57 @@ is_gimple_mem_ref_addr (tree t) || decl_address_invariant_p (TREE_OPERAND (t, 0))))); } +/* Hold trees marked addressable during expand. */ + +static hash_set *mark_addressable_queue; + +/* Mark X as addressable or queue it up if called during expand. We + don't want to apply it immediately during expand because decls are + made addressable at that point due to RTL-only concerns, such as + uses of memcpy for block moves, and TREE_ADDRESSABLE changes + is_gimple_reg, which might make it seem like a variable that used + to be a gimple_reg shouldn't have been an SSA name. So we queue up + this flag setting and only apply it when we're done with GIMPLE and + only RTL issues matter. */ + +static void +mark_addressable_1 (tree x) +{ + if (!currently_expanding_to_rtl) + { + TREE_ADDRESSABLE (x) = 1; + return; + } + + if (!mark_addressable_queue) + mark_addressable_queue = new hash_set(); + mark_addressable_queue->add (x); +} + +/* Adaptor for mark_addressable_1 for use in hash_set traversal. */ + +bool +mark_addressable_2 (tree const &x, void * ATTRIBUTE_UNUSED = NULL) +{ + mark_addressable_1 (x); + return false; +} + +/* Mark all queued trees as addressable, and empty the queue. To be + called right after clearing CURRENTLY_EXPANDING_TO_RTL. */ + +void +flush_mark_addressable_queue () +{ + gcc_assert (!currently_expanding_to_rtl); + if (mark_addressable_queue) + { + mark_addressable_queue->traverse (NULL); + delete mark_addressable_queue; + mark_addressable_queue = NULL; + } +} + /* Mark X addressable. Unlike the langhook we expect X to be in gimple form and we don't do any syntax checking. */ @@ -832,7 +885,7 @@ mark_addressable (tree x) && TREE_CODE (x) != PARM_DECL && TREE_CODE (x) != RESULT_DECL) return; - TREE_ADDRESSABLE (x) = 1; + mark_addressable_1 (x); /* Also mark the artificial SSA_NAME that points to the partition of X. */ if (TREE_CODE (x) == VAR_DECL @@ -843,7 +896,7 @@ mark_addressable (tree x) { tree *namep = cfun->gimple_df->decls_to_pointers->get (x); if (namep) - TREE_ADDRESSABLE (*namep) = 1; + mark_addressable_1 (*namep); } } diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h index 3d1c89f..2917d2752c 100644 --- a/gcc/gimple-expr.h +++ b/gcc/gimple-expr.h @@ -52,6 +52,7 @@ extern bool is_gimple_asm_val (tree); extern bool is_gimple_min_lval (tree); extern bool is_gimple_call_addr (tree); extern bool is_gimple_mem_ref_addr (tree); +extern void flush_mark_addressable_queue (void); extern void mark_addressable (tree); extern bool is_gimple_reg_rhs (tree); -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer