Commit 1b223a9f by Alexandre Oliva Committed by Alexandre Oliva

defer mark_addressable calls during expand till the end of expand

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.

From-SVN: r229696
parent ec95cd47
2015-11-03 Alexandre Oliva <aoliva@redhat.com>
* 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.
2015-11-02 Alexandre Oliva <aoliva@redhat.com> 2015-11-02 Alexandre Oliva <aoliva@redhat.com>
* tree-ssa-ifcombine.c (tree_ssa_ifcombine_bb_1): Factor out * tree-ssa-ifcombine.c (tree_ssa_ifcombine_bb_1): Factor out
...@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see
#include "internal-fn.h" #include "internal-fn.h"
#include "tree-eh.h" #include "tree-eh.h"
#include "gimple-iterator.h" #include "gimple-iterator.h"
#include "gimple-expr.h"
#include "gimple-walk.h" #include "gimple-walk.h"
#include "tree-cfg.h" #include "tree-cfg.h"
#include "tree-dfa.h" #include "tree-dfa.h"
...@@ -6368,6 +6369,8 @@ pass_expand::execute (function *fun) ...@@ -6368,6 +6369,8 @@ pass_expand::execute (function *fun)
/* We're done expanding trees to RTL. */ /* We're done expanding trees to RTL. */
currently_expanding_to_rtl = 0; currently_expanding_to_rtl = 0;
flush_mark_addressable_queue ();
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (fun)->next_bb, FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (fun)->next_bb,
EXIT_BLOCK_PTR_FOR_FN (fun), next_bb) EXIT_BLOCK_PTR_FOR_FN (fun), next_bb)
{ {
......
...@@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see
#include "gimplify.h" #include "gimplify.h"
#include "stor-layout.h" #include "stor-layout.h"
#include "demangle.h" #include "demangle.h"
#include "hash-set.h"
#include "rtl.h"
/* ----- Type related ----- */ /* ----- Type related ----- */
...@@ -817,6 +819,57 @@ is_gimple_mem_ref_addr (tree t) ...@@ -817,6 +819,57 @@ is_gimple_mem_ref_addr (tree t)
|| decl_address_invariant_p (TREE_OPERAND (t, 0))))); || decl_address_invariant_p (TREE_OPERAND (t, 0)))));
} }
/* Hold trees marked addressable during expand. */
static hash_set<tree> *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<tree>();
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<void*, mark_addressable_2> (NULL);
delete mark_addressable_queue;
mark_addressable_queue = NULL;
}
}
/* Mark X addressable. Unlike the langhook we expect X to be in gimple /* Mark X addressable. Unlike the langhook we expect X to be in gimple
form and we don't do any syntax checking. */ form and we don't do any syntax checking. */
...@@ -832,7 +885,7 @@ mark_addressable (tree x) ...@@ -832,7 +885,7 @@ mark_addressable (tree x)
&& TREE_CODE (x) != PARM_DECL && TREE_CODE (x) != PARM_DECL
&& TREE_CODE (x) != RESULT_DECL) && TREE_CODE (x) != RESULT_DECL)
return; return;
TREE_ADDRESSABLE (x) = 1; mark_addressable_1 (x);
/* Also mark the artificial SSA_NAME that points to the partition of X. */ /* Also mark the artificial SSA_NAME that points to the partition of X. */
if (TREE_CODE (x) == VAR_DECL if (TREE_CODE (x) == VAR_DECL
...@@ -843,7 +896,7 @@ mark_addressable (tree x) ...@@ -843,7 +896,7 @@ mark_addressable (tree x)
{ {
tree *namep = cfun->gimple_df->decls_to_pointers->get (x); tree *namep = cfun->gimple_df->decls_to_pointers->get (x);
if (namep) if (namep)
TREE_ADDRESSABLE (*namep) = 1; mark_addressable_1 (*namep);
} }
} }
......
...@@ -52,6 +52,7 @@ extern bool is_gimple_asm_val (tree); ...@@ -52,6 +52,7 @@ extern bool is_gimple_asm_val (tree);
extern bool is_gimple_min_lval (tree); extern bool is_gimple_min_lval (tree);
extern bool is_gimple_call_addr (tree); extern bool is_gimple_call_addr (tree);
extern bool is_gimple_mem_ref_addr (tree); extern bool is_gimple_mem_ref_addr (tree);
extern void flush_mark_addressable_queue (void);
extern void mark_addressable (tree); extern void mark_addressable (tree);
extern bool is_gimple_reg_rhs (tree); extern bool is_gimple_reg_rhs (tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment