re PR middle-end/59208 (ice in initialize_flags_in_bb)

2013-11-29  Richard Biener  <rguenther@suse.de>

	PR middle-end/59208
	* tree-ssa-operands.h (fini_ssa_operands, verify_ssa_operands,
	free_stmt_operands, update_stmt_operands): Add struct function
	argument.
	* tree-ssa-operands.c: Remove uses of cfun, propagate struct
	function argument from fini_ssa_operands, verify_ssa_operands,
	free_stmt_operands and update_stmt_operands everywhere.
	* tree-ssanames.h (release_ssa_name_fn): New.
	(release_ssa_name): Inline wrapper around release_ssa_name_fn.
	* tree-ssanames.c (release_ssa_name): Rename to ...
	(release_ssa_name_fn): ... this and add struct function argument.
	* gimple-ssa.h (update_stmt, update_stmt_if_modified): Adjust.
	(update_stmt_fn): New function.
	* tree-cfg.c (move_block_to_fn): Adjust.
	* tree-if-conv.c (free_bb_predicate): Likewise.
	* tree-ssa.c (verify_ssa): Likewise.
	(delete_tree_ssa): Likewise.
	* gimple-pretty-print.c (dump_gimple_mem_ops): Remove guard.
	* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Call
	update_stmt_fn instead of update_stmt.

	* g++.dg/torture/pr59208.C: New testcase.

From-SVN: r205528
This commit is contained in:
Richard Biener 2013-11-29 14:37:07 +00:00 committed by Richard Biener
parent 78a14aa81e
commit 6a58cccac6
12 changed files with 176 additions and 128 deletions

View File

@ -1,3 +1,26 @@
2013-11-29 Richard Biener <rguenther@suse.de>
PR middle-end/59208
* tree-ssa-operands.h (fini_ssa_operands, verify_ssa_operands,
free_stmt_operands, update_stmt_operands): Add struct function
argument.
* tree-ssa-operands.c: Remove uses of cfun, propagate struct
function argument from fini_ssa_operands, verify_ssa_operands,
free_stmt_operands and update_stmt_operands everywhere.
* tree-ssanames.h (release_ssa_name_fn): New.
(release_ssa_name): Inline wrapper around release_ssa_name_fn.
* tree-ssanames.c (release_ssa_name): Rename to ...
(release_ssa_name_fn): ... this and add struct function argument.
* gimple-ssa.h (update_stmt, update_stmt_if_modified): Adjust.
(update_stmt_fn): New function.
* tree-cfg.c (move_block_to_fn): Adjust.
* tree-if-conv.c (free_bb_predicate): Likewise.
* tree-ssa.c (verify_ssa): Likewise.
(delete_tree_ssa): Likewise.
* gimple-pretty-print.c (dump_gimple_mem_ops): Remove guard.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Call
update_stmt_fn instead of update_stmt.
2013-11-29 Yvan Roux <yvan.roux@linaro.org> 2013-11-29 Yvan Roux <yvan.roux@linaro.org>
* config/arm/arm.h (THUMB_SECONDARY_INPUT_RELOAD_CLASS): Return NO_REGS * config/arm/arm.h (THUMB_SECONDARY_INPUT_RELOAD_CLASS): Return NO_REGS

View File

@ -1468,7 +1468,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
{ {
new_stmt = e->call_stmt; new_stmt = e->call_stmt;
gimple_call_set_fndecl (new_stmt, e->callee->decl); gimple_call_set_fndecl (new_stmt, e->callee->decl);
update_stmt (new_stmt); update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
} }
cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, new_stmt, false); cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, new_stmt, false);

View File

@ -2021,10 +2021,6 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
tree vdef = gimple_vdef (gs); tree vdef = gimple_vdef (gs);
tree vuse = gimple_vuse (gs); tree vuse = gimple_vuse (gs);
if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
|| !gimple_references_memory_p (gs))
return;
if (vdef != NULL_TREE) if (vdef != NULL_TREE)
{ {
pp_string (buffer, "# "); pp_string (buffer, "# ");

View File

@ -141,7 +141,7 @@ update_stmt (gimple s)
if (gimple_has_ops (s)) if (gimple_has_ops (s))
{ {
gimple_set_modified (s, true); gimple_set_modified (s, true);
update_stmt_operands (s); update_stmt_operands (cfun, s);
} }
} }
@ -151,7 +151,19 @@ static inline void
update_stmt_if_modified (gimple s) update_stmt_if_modified (gimple s)
{ {
if (gimple_modified_p (s)) if (gimple_modified_p (s))
update_stmt_operands (s); update_stmt_operands (cfun, s);
}
/* Mark statement S as modified, and update it. */
static inline void
update_stmt_fn (struct function *fn, gimple s)
{
if (gimple_has_ops (s))
{
gimple_set_modified (s, true);
update_stmt_operands (fn, s);
}
} }

View File

@ -1,3 +1,8 @@
2013-11-29 Richard Biener <rguenther@suse.de>
PR middle-end/59208
* g++.dg/torture/pr59208.C: New testcase.
2013-11-29 Jakub Jelinek <jakub@redhat.com> 2013-11-29 Jakub Jelinek <jakub@redhat.com>
Yury Gribov <y.gribov@samsung.com> Yury Gribov <y.gribov@samsung.com>

View File

@ -6540,7 +6540,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
/* We cannot leave any operands allocated from the operand caches of /* We cannot leave any operands allocated from the operand caches of
the current function. */ the current function. */
free_stmt_operands (stmt); free_stmt_operands (cfun, stmt);
push_cfun (dest_cfun); push_cfun (dest_cfun);
update_stmt (stmt); update_stmt (stmt);
pop_cfun (); pop_cfun ();

View File

@ -212,7 +212,7 @@ free_bb_predicate (basic_block bb)
gimple_stmt_iterator i; gimple_stmt_iterator i;
for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i)) for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i))
free_stmt_operands (gsi_stmt (i)); free_stmt_operands (cfun, gsi_stmt (i));
} }
free (bb->aux); free (bb->aux);

View File

@ -129,7 +129,7 @@ static tree build_vuse;
compilations of multiple functions. */ compilations of multiple functions. */
static bitmap_obstack operands_bitmap_obstack; static bitmap_obstack operands_bitmap_obstack;
static void get_expr_operands (gimple, tree *, int); static void get_expr_operands (struct function *, gimple, tree *, int);
/* Number of functions with initialized ssa_operands. */ /* Number of functions with initialized ssa_operands. */
static int n_initialized = 0; static int n_initialized = 0;
@ -217,7 +217,7 @@ init_ssa_operands (struct function *fn)
/* Dispose of anything required by the operand routines. */ /* Dispose of anything required by the operand routines. */
void void
fini_ssa_operands (void) fini_ssa_operands (struct function *fn)
{ {
struct ssa_operand_memory_d *ptr; struct ssa_operand_memory_d *ptr;
@ -228,49 +228,49 @@ fini_ssa_operands (void)
build_vuse = NULL_TREE; build_vuse = NULL_TREE;
} }
gimple_ssa_operands (cfun)->free_uses = NULL; gimple_ssa_operands (fn)->free_uses = NULL;
while ((ptr = gimple_ssa_operands (cfun)->operand_memory) != NULL) while ((ptr = gimple_ssa_operands (fn)->operand_memory) != NULL)
{ {
gimple_ssa_operands (cfun)->operand_memory gimple_ssa_operands (fn)->operand_memory
= gimple_ssa_operands (cfun)->operand_memory->next; = gimple_ssa_operands (fn)->operand_memory->next;
ggc_free (ptr); ggc_free (ptr);
} }
gimple_ssa_operands (cfun)->ops_active = false; gimple_ssa_operands (fn)->ops_active = false;
if (!n_initialized) if (!n_initialized)
bitmap_obstack_release (&operands_bitmap_obstack); bitmap_obstack_release (&operands_bitmap_obstack);
cfun->gimple_df->vop = NULL_TREE; fn->gimple_df->vop = NULL_TREE;
} }
/* Return memory for an operand of size SIZE. */ /* Return memory for an operand of size SIZE. */
static inline void * static inline void *
ssa_operand_alloc (unsigned size) ssa_operand_alloc (struct function *fn, unsigned size)
{ {
char *ptr; char *ptr;
gcc_assert (size == sizeof (struct use_optype_d)); gcc_assert (size == sizeof (struct use_optype_d));
if (gimple_ssa_operands (cfun)->operand_memory_index + size if (gimple_ssa_operands (fn)->operand_memory_index + size
>= gimple_ssa_operands (cfun)->ssa_operand_mem_size) >= gimple_ssa_operands (fn)->ssa_operand_mem_size)
{ {
struct ssa_operand_memory_d *ptr; struct ssa_operand_memory_d *ptr;
switch (gimple_ssa_operands (cfun)->ssa_operand_mem_size) switch (gimple_ssa_operands (fn)->ssa_operand_mem_size)
{ {
case OP_SIZE_INIT: case OP_SIZE_INIT:
gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_1; gimple_ssa_operands (fn)->ssa_operand_mem_size = OP_SIZE_1;
break; break;
case OP_SIZE_1: case OP_SIZE_1:
gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_2; gimple_ssa_operands (fn)->ssa_operand_mem_size = OP_SIZE_2;
break; break;
case OP_SIZE_2: case OP_SIZE_2:
case OP_SIZE_3: case OP_SIZE_3:
gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_3; gimple_ssa_operands (fn)->ssa_operand_mem_size = OP_SIZE_3;
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
@ -278,16 +278,16 @@ ssa_operand_alloc (unsigned size)
ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *) ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *)
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size); + gimple_ssa_operands (fn)->ssa_operand_mem_size);
ptr->next = gimple_ssa_operands (cfun)->operand_memory; ptr->next = gimple_ssa_operands (fn)->operand_memory;
gimple_ssa_operands (cfun)->operand_memory = ptr; gimple_ssa_operands (fn)->operand_memory = ptr;
gimple_ssa_operands (cfun)->operand_memory_index = 0; gimple_ssa_operands (fn)->operand_memory_index = 0;
} }
ptr = &(gimple_ssa_operands (cfun)->operand_memory ptr = &(gimple_ssa_operands (fn)->operand_memory
->mem[gimple_ssa_operands (cfun)->operand_memory_index]); ->mem[gimple_ssa_operands (fn)->operand_memory_index]);
gimple_ssa_operands (cfun)->operand_memory_index += size; gimple_ssa_operands (fn)->operand_memory_index += size;
return ptr; return ptr;
} }
@ -295,18 +295,18 @@ ssa_operand_alloc (unsigned size)
/* Allocate a USE operand. */ /* Allocate a USE operand. */
static inline struct use_optype_d * static inline struct use_optype_d *
alloc_use (void) alloc_use (struct function *fn)
{ {
struct use_optype_d *ret; struct use_optype_d *ret;
if (gimple_ssa_operands (cfun)->free_uses) if (gimple_ssa_operands (fn)->free_uses)
{ {
ret = gimple_ssa_operands (cfun)->free_uses; ret = gimple_ssa_operands (fn)->free_uses;
gimple_ssa_operands (cfun)->free_uses gimple_ssa_operands (fn)->free_uses
= gimple_ssa_operands (cfun)->free_uses->next; = gimple_ssa_operands (fn)->free_uses->next;
} }
else else
ret = (struct use_optype_d *) ret = (struct use_optype_d *)
ssa_operand_alloc (sizeof (struct use_optype_d)); ssa_operand_alloc (fn, sizeof (struct use_optype_d));
return ret; return ret;
} }
@ -314,11 +314,11 @@ alloc_use (void)
/* Adds OP to the list of uses of statement STMT after LAST. */ /* Adds OP to the list of uses of statement STMT after LAST. */
static inline use_optype_p static inline use_optype_p
add_use_op (gimple stmt, tree *op, use_optype_p last) add_use_op (struct function *fn, gimple stmt, tree *op, use_optype_p last)
{ {
use_optype_p new_use; use_optype_p new_use;
new_use = alloc_use (); new_use = alloc_use (fn);
USE_OP_PTR (new_use)->use = op; USE_OP_PTR (new_use)->use = op;
link_imm_use_stmt (USE_OP_PTR (new_use), *op, stmt); link_imm_use_stmt (USE_OP_PTR (new_use), *op, stmt);
last->next = new_use; last->next = new_use;
@ -332,7 +332,7 @@ add_use_op (gimple stmt, tree *op, use_optype_p last)
TODO -- Make build_defs vec of tree *. */ TODO -- Make build_defs vec of tree *. */
static inline void static inline void
finalize_ssa_defs (gimple stmt) finalize_ssa_defs (struct function *fn, gimple stmt)
{ {
/* Pre-pend the vdef we may have built. */ /* Pre-pend the vdef we may have built. */
if (build_vdef != NULL_TREE) if (build_vdef != NULL_TREE)
@ -352,7 +352,7 @@ finalize_ssa_defs (gimple stmt)
if (TREE_CODE (gimple_vdef (stmt)) == SSA_NAME) if (TREE_CODE (gimple_vdef (stmt)) == SSA_NAME)
{ {
unlink_stmt_vdef (stmt); unlink_stmt_vdef (stmt);
release_ssa_name (gimple_vdef (stmt)); release_ssa_name_fn (fn, gimple_vdef (stmt));
} }
gimple_set_vdef (stmt, NULL_TREE); gimple_set_vdef (stmt, NULL_TREE);
} }
@ -361,8 +361,8 @@ finalize_ssa_defs (gimple stmt)
if (gimple_vdef (stmt) if (gimple_vdef (stmt)
&& TREE_CODE (gimple_vdef (stmt)) != SSA_NAME) && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME)
{ {
cfun->gimple_df->rename_vops = 1; fn->gimple_df->rename_vops = 1;
cfun->gimple_df->ssa_renaming_needed = 1; fn->gimple_df->ssa_renaming_needed = 1;
} }
} }
@ -371,7 +371,7 @@ finalize_ssa_defs (gimple stmt)
TODO -- Make build_uses vec of tree *. */ TODO -- Make build_uses vec of tree *. */
static inline void static inline void
finalize_ssa_uses (gimple stmt) finalize_ssa_uses (struct function *fn, gimple stmt)
{ {
unsigned new_i; unsigned new_i;
struct use_optype_d new_list; struct use_optype_d new_list;
@ -405,8 +405,8 @@ finalize_ssa_uses (gimple stmt)
{ {
for (ptr = old_ops; ptr; ptr = ptr->next) for (ptr = old_ops; ptr; ptr = ptr->next)
delink_imm_use (USE_OP_PTR (ptr)); delink_imm_use (USE_OP_PTR (ptr));
old_ops->next = gimple_ssa_operands (cfun)->free_uses; old_ops->next = gimple_ssa_operands (fn)->free_uses;
gimple_ssa_operands (cfun)->free_uses = old_ops; gimple_ssa_operands (fn)->free_uses = old_ops;
} }
/* If we added a VUSE, make sure to set the operand if it is not already /* If we added a VUSE, make sure to set the operand if it is not already
@ -414,16 +414,16 @@ finalize_ssa_uses (gimple stmt)
if (build_vuse != NULL_TREE if (build_vuse != NULL_TREE
&& gimple_vuse (stmt) == NULL_TREE) && gimple_vuse (stmt) == NULL_TREE)
{ {
gimple_set_vuse (stmt, gimple_vop (cfun)); gimple_set_vuse (stmt, gimple_vop (fn));
cfun->gimple_df->rename_vops = 1; fn->gimple_df->rename_vops = 1;
cfun->gimple_df->ssa_renaming_needed = 1; fn->gimple_df->ssa_renaming_needed = 1;
} }
/* Now create nodes for all the new nodes. */ /* Now create nodes for all the new nodes. */
for (new_i = 0; new_i < build_uses.length (); new_i++) for (new_i = 0; new_i < build_uses.length (); new_i++)
{ {
tree *op = (tree *) build_uses[new_i]; tree *op = (tree *) build_uses[new_i];
last = add_use_op (stmt, op, last); last = add_use_op (fn, stmt, op, last);
} }
/* Now set the stmt's operands. */ /* Now set the stmt's operands. */
@ -446,10 +446,10 @@ cleanup_build_arrays (void)
/* Finalize all the build vectors, fill the new ones into INFO. */ /* Finalize all the build vectors, fill the new ones into INFO. */
static inline void static inline void
finalize_ssa_stmt_operands (gimple stmt) finalize_ssa_stmt_operands (struct function *fn, gimple stmt)
{ {
finalize_ssa_defs (stmt); finalize_ssa_defs (fn, stmt);
finalize_ssa_uses (stmt); finalize_ssa_uses (fn, stmt);
cleanup_build_arrays (); cleanup_build_arrays ();
} }
@ -509,7 +509,8 @@ append_vuse (tree var)
/* Add virtual operands for STMT. FLAGS is as in get_expr_operands. */ /* Add virtual operands for STMT. FLAGS is as in get_expr_operands. */
static void static void
add_virtual_operand (gimple stmt ATTRIBUTE_UNUSED, int flags) add_virtual_operand (struct function *fn,
gimple stmt ATTRIBUTE_UNUSED, int flags)
{ {
/* Add virtual operands to the stmt, unless the caller has specifically /* Add virtual operands to the stmt, unless the caller has specifically
requested not to do that (used when adding operands inside an requested not to do that (used when adding operands inside an
@ -520,9 +521,9 @@ add_virtual_operand (gimple stmt ATTRIBUTE_UNUSED, int flags)
gcc_assert (!is_gimple_debug (stmt)); gcc_assert (!is_gimple_debug (stmt));
if (flags & opf_def) if (flags & opf_def)
append_vdef (gimple_vop (cfun)); append_vdef (gimple_vop (fn));
else else
append_vuse (gimple_vop (cfun)); append_vuse (gimple_vop (fn));
} }
@ -532,7 +533,7 @@ add_virtual_operand (gimple stmt ATTRIBUTE_UNUSED, int flags)
added to virtual operands. */ added to virtual operands. */
static void static void
add_stmt_operand (tree *var_p, gimple stmt, int flags) add_stmt_operand (struct function *fn, tree *var_p, gimple stmt, int flags)
{ {
tree var = *var_p; tree var = *var_p;
@ -546,7 +547,7 @@ add_stmt_operand (tree *var_p, gimple stmt, int flags)
else else
append_use (var_p); append_use (var_p);
if (DECL_P (*var_p)) if (DECL_P (*var_p))
cfun->gimple_df->ssa_renaming_needed = 1; fn->gimple_df->ssa_renaming_needed = 1;
} }
else else
{ {
@ -556,7 +557,7 @@ add_stmt_operand (tree *var_p, gimple stmt, int flags)
gimple_set_has_volatile_ops (stmt, true); gimple_set_has_volatile_ops (stmt, true);
/* The variable is a memory access. Add virtual operands. */ /* The variable is a memory access. Add virtual operands. */
add_virtual_operand (stmt, flags); add_virtual_operand (fn, stmt, flags);
} }
} }
@ -596,7 +597,8 @@ mark_address_taken (tree ref)
FLAGS is as in get_expr_operands. */ FLAGS is as in get_expr_operands. */
static void static void
get_indirect_ref_operands (gimple stmt, tree expr, int flags) get_indirect_ref_operands (struct function *fn,
gimple stmt, tree expr, int flags)
{ {
tree *pptr = &TREE_OPERAND (expr, 0); tree *pptr = &TREE_OPERAND (expr, 0);
@ -605,10 +607,10 @@ get_indirect_ref_operands (gimple stmt, tree expr, int flags)
gimple_set_has_volatile_ops (stmt, true); gimple_set_has_volatile_ops (stmt, true);
/* Add the VOP. */ /* Add the VOP. */
add_virtual_operand (stmt, flags); add_virtual_operand (fn, stmt, flags);
/* If requested, add a USE operand for the base pointer. */ /* If requested, add a USE operand for the base pointer. */
get_expr_operands (stmt, pptr, get_expr_operands (fn, stmt, pptr,
opf_non_addressable | opf_use opf_non_addressable | opf_use
| (flags & (opf_no_vops|opf_not_non_addressable))); | (flags & (opf_no_vops|opf_not_non_addressable)));
} }
@ -617,18 +619,21 @@ get_indirect_ref_operands (gimple stmt, tree expr, int flags)
/* A subroutine of get_expr_operands to handle TARGET_MEM_REF. */ /* A subroutine of get_expr_operands to handle TARGET_MEM_REF. */
static void static void
get_tmr_operands (gimple stmt, tree expr, int flags) get_tmr_operands (struct function *fn, gimple stmt, tree expr, int flags)
{ {
if (!(flags & opf_no_vops) if (!(flags & opf_no_vops)
&& TREE_THIS_VOLATILE (expr)) && TREE_THIS_VOLATILE (expr))
gimple_set_has_volatile_ops (stmt, true); gimple_set_has_volatile_ops (stmt, true);
/* First record the real operands. */ /* First record the real operands. */
get_expr_operands (stmt, &TMR_BASE (expr), opf_use | (flags & opf_no_vops)); get_expr_operands (fn, stmt,
get_expr_operands (stmt, &TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); &TMR_BASE (expr), opf_use | (flags & opf_no_vops));
get_expr_operands (stmt, &TMR_INDEX2 (expr), opf_use | (flags & opf_no_vops)); get_expr_operands (fn, stmt,
&TMR_INDEX (expr), opf_use | (flags & opf_no_vops));
get_expr_operands (fn, stmt,
&TMR_INDEX2 (expr), opf_use | (flags & opf_no_vops));
add_virtual_operand (stmt, flags); add_virtual_operand (fn, stmt, flags);
} }
@ -636,7 +641,7 @@ get_tmr_operands (gimple stmt, tree expr, int flags)
escape, add them to the VDEF/VUSE lists for it. */ escape, add them to the VDEF/VUSE lists for it. */
static void static void
maybe_add_call_vops (gimple stmt) maybe_add_call_vops (struct function *fn, gimple stmt)
{ {
int call_flags = gimple_call_flags (stmt); int call_flags = gimple_call_flags (stmt);
@ -649,9 +654,9 @@ maybe_add_call_vops (gimple stmt)
A 'noreturn' function might, but since we don't return anyway A 'noreturn' function might, but since we don't return anyway
there is no point in recording that. */ there is no point in recording that. */
if (!(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN))) if (!(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
add_virtual_operand (stmt, opf_def); add_virtual_operand (fn, stmt, opf_def);
else if (!(call_flags & ECF_CONST)) else if (!(call_flags & ECF_CONST))
add_virtual_operand (stmt, opf_use); add_virtual_operand (fn, stmt, opf_use);
} }
} }
@ -659,7 +664,7 @@ maybe_add_call_vops (gimple stmt)
/* Scan operands in the ASM_EXPR stmt referred to in INFO. */ /* Scan operands in the ASM_EXPR stmt referred to in INFO. */
static void static void
get_asm_expr_operands (gimple stmt) get_asm_expr_operands (struct function *fn, gimple stmt)
{ {
size_t i, noutputs; size_t i, noutputs;
const char **oconstraints; const char **oconstraints;
@ -686,7 +691,8 @@ get_asm_expr_operands (gimple stmt)
if (!allows_reg && allows_mem) if (!allows_reg && allows_mem)
mark_address_taken (TREE_VALUE (link)); mark_address_taken (TREE_VALUE (link));
get_expr_operands (stmt, &TREE_VALUE (link), opf_def | opf_not_non_addressable); get_expr_operands (fn, stmt,
&TREE_VALUE (link), opf_def | opf_not_non_addressable);
} }
/* Gather all input operands. */ /* Gather all input operands. */
@ -702,12 +708,12 @@ get_asm_expr_operands (gimple stmt)
if (!allows_reg && allows_mem) if (!allows_reg && allows_mem)
mark_address_taken (TREE_VALUE (link)); mark_address_taken (TREE_VALUE (link));
get_expr_operands (stmt, &TREE_VALUE (link), opf_not_non_addressable); get_expr_operands (fn, stmt, &TREE_VALUE (link), opf_not_non_addressable);
} }
/* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */ /* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */
if (gimple_asm_clobbers_memory_p (stmt)) if (gimple_asm_clobbers_memory_p (stmt))
add_virtual_operand (stmt, opf_def); add_virtual_operand (fn, stmt, opf_def);
} }
@ -716,7 +722,7 @@ get_asm_expr_operands (gimple stmt)
interpret the operands found. */ interpret the operands found. */
static void static void
get_expr_operands (gimple stmt, tree *expr_p, int flags) get_expr_operands (struct function *fn, gimple stmt, tree *expr_p, int flags)
{ {
enum tree_code code; enum tree_code code;
enum tree_code_class codeclass; enum tree_code_class codeclass;
@ -755,7 +761,7 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
here are ARRAY_REF indices which will always be real operands here are ARRAY_REF indices which will always be real operands
(GIMPLE does not allow non-registers as array indices). */ (GIMPLE does not allow non-registers as array indices). */
flags |= opf_no_vops; flags |= opf_no_vops;
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0),
flags | opf_not_non_addressable); flags | opf_not_non_addressable);
return; return;
@ -763,7 +769,7 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
case VAR_DECL: case VAR_DECL:
case PARM_DECL: case PARM_DECL:
case RESULT_DECL: case RESULT_DECL:
add_stmt_operand (expr_p, stmt, flags); add_stmt_operand (fn, expr_p, stmt, flags);
return; return;
case DEBUG_EXPR_DECL: case DEBUG_EXPR_DECL:
@ -771,11 +777,11 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
return; return;
case MEM_REF: case MEM_REF:
get_indirect_ref_operands (stmt, expr, flags); get_indirect_ref_operands (fn, stmt, expr, flags);
return; return;
case TARGET_MEM_REF: case TARGET_MEM_REF:
get_tmr_operands (stmt, expr, flags); get_tmr_operands (fn, stmt, expr, flags);
return; return;
case ARRAY_REF: case ARRAY_REF:
@ -788,20 +794,20 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
&& TREE_THIS_VOLATILE (expr)) && TREE_THIS_VOLATILE (expr))
gimple_set_has_volatile_ops (stmt, true); gimple_set_has_volatile_ops (stmt, true);
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), flags);
if (code == COMPONENT_REF) if (code == COMPONENT_REF)
{ {
if (!(flags & opf_no_vops) if (!(flags & opf_no_vops)
&& TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1))) && TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1)))
gimple_set_has_volatile_ops (stmt, true); gimple_set_has_volatile_ops (stmt, true);
get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 2), uflags);
} }
else if (code == ARRAY_REF || code == ARRAY_RANGE_REF) else if (code == ARRAY_REF || code == ARRAY_RANGE_REF)
{ {
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 1), uflags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 2), uflags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 3), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 3), uflags);
} }
return; return;
@ -810,16 +816,16 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
case WITH_SIZE_EXPR: case WITH_SIZE_EXPR:
/* WITH_SIZE_EXPR is a pass-through reference to its first argument, /* WITH_SIZE_EXPR is a pass-through reference to its first argument,
and an rvalue reference to its second argument. */ and an rvalue reference to its second argument. */
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 1), uflags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), flags);
return; return;
case COND_EXPR: case COND_EXPR:
case VEC_COND_EXPR: case VEC_COND_EXPR:
case VEC_PERM_EXPR: case VEC_PERM_EXPR:
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), uflags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 1), uflags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 2), uflags);
return; return;
case CONSTRUCTOR: case CONSTRUCTOR:
@ -839,7 +845,7 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
for (idx = 0; for (idx = 0;
vec_safe_iterate (CONSTRUCTOR_ELTS (expr), idx, &ce); vec_safe_iterate (CONSTRUCTOR_ELTS (expr), idx, &ce);
idx++) idx++)
get_expr_operands (stmt, &ce->value, uflags); get_expr_operands (fn, stmt, &ce->value, uflags);
return; return;
} }
@ -852,7 +858,7 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
do_unary: do_unary:
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), flags);
return; return;
case COMPOUND_EXPR: case COMPOUND_EXPR:
@ -860,8 +866,8 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
case ASSERT_EXPR: case ASSERT_EXPR:
do_binary: do_binary:
{ {
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), flags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 1), flags);
return; return;
} }
@ -871,9 +877,9 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
case WIDEN_MULT_MINUS_EXPR: case WIDEN_MULT_MINUS_EXPR:
case FMA_EXPR: case FMA_EXPR:
{ {
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 0), flags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 1), flags);
get_expr_operands (stmt, &TREE_OPERAND (expr, 2), flags); get_expr_operands (fn, stmt, &TREE_OPERAND (expr, 2), flags);
return; return;
} }
@ -907,7 +913,7 @@ get_expr_operands (gimple stmt, tree *expr_p, int flags)
build_* operand vectors will have potential operands in them. */ build_* operand vectors will have potential operands in them. */
static void static void
parse_ssa_operands (gimple stmt) parse_ssa_operands (struct function *fn, gimple stmt)
{ {
enum gimple_code code = gimple_code (stmt); enum gimple_code code = gimple_code (stmt);
size_t i, n, start = 0; size_t i, n, start = 0;
@ -915,32 +921,32 @@ parse_ssa_operands (gimple stmt)
switch (code) switch (code)
{ {
case GIMPLE_ASM: case GIMPLE_ASM:
get_asm_expr_operands (stmt); get_asm_expr_operands (fn, stmt);
break; break;
case GIMPLE_TRANSACTION: case GIMPLE_TRANSACTION:
/* The start of a transaction is a memory barrier. */ /* The start of a transaction is a memory barrier. */
add_virtual_operand (stmt, opf_def | opf_use); add_virtual_operand (fn, stmt, opf_def | opf_use);
break; break;
case GIMPLE_DEBUG: case GIMPLE_DEBUG:
if (gimple_debug_bind_p (stmt) if (gimple_debug_bind_p (stmt)
&& gimple_debug_bind_has_value_p (stmt)) && gimple_debug_bind_has_value_p (stmt))
get_expr_operands (stmt, gimple_debug_bind_get_value_ptr (stmt), get_expr_operands (fn, stmt, gimple_debug_bind_get_value_ptr (stmt),
opf_use | opf_no_vops); opf_use | opf_no_vops);
break; break;
case GIMPLE_RETURN: case GIMPLE_RETURN:
append_vuse (gimple_vop (cfun)); append_vuse (gimple_vop (fn));
goto do_default; goto do_default;
case GIMPLE_CALL: case GIMPLE_CALL:
/* Add call-clobbered operands, if needed. */ /* Add call-clobbered operands, if needed. */
maybe_add_call_vops (stmt); maybe_add_call_vops (fn, stmt);
/* FALLTHRU */ /* FALLTHRU */
case GIMPLE_ASSIGN: case GIMPLE_ASSIGN:
get_expr_operands (stmt, gimple_op_ptr (stmt, 0), opf_def); get_expr_operands (fn, stmt, gimple_op_ptr (stmt, 0), opf_def);
start = 1; start = 1;
/* FALLTHRU */ /* FALLTHRU */
@ -948,7 +954,7 @@ parse_ssa_operands (gimple stmt)
do_default: do_default:
n = gimple_num_ops (stmt); n = gimple_num_ops (stmt);
for (i = start; i < n; i++) for (i = start; i < n; i++)
get_expr_operands (stmt, gimple_op_ptr (stmt, i), opf_use); get_expr_operands (fn, stmt, gimple_op_ptr (stmt, i), opf_use);
break; break;
} }
} }
@ -957,20 +963,20 @@ parse_ssa_operands (gimple stmt)
/* Create an operands cache for STMT. */ /* Create an operands cache for STMT. */
static void static void
build_ssa_operands (gimple stmt) build_ssa_operands (struct function *fn, gimple stmt)
{ {
/* Initially assume that the statement has no volatile operands. */ /* Initially assume that the statement has no volatile operands. */
gimple_set_has_volatile_ops (stmt, false); gimple_set_has_volatile_ops (stmt, false);
start_ssa_stmt_operands (); start_ssa_stmt_operands ();
parse_ssa_operands (stmt); parse_ssa_operands (fn, stmt);
finalize_ssa_stmt_operands (stmt); finalize_ssa_stmt_operands (fn, stmt);
} }
/* Verifies SSA statement operands. */ /* Verifies SSA statement operands. */
DEBUG_FUNCTION bool DEBUG_FUNCTION bool
verify_ssa_operands (gimple stmt) verify_ssa_operands (struct function *fn, gimple stmt)
{ {
use_operand_p use_p; use_operand_p use_p;
def_operand_p def_p; def_operand_p def_p;
@ -982,7 +988,7 @@ verify_ssa_operands (gimple stmt)
/* build_ssa_operands w/o finalizing them. */ /* build_ssa_operands w/o finalizing them. */
gimple_set_has_volatile_ops (stmt, false); gimple_set_has_volatile_ops (stmt, false);
start_ssa_stmt_operands (); start_ssa_stmt_operands ();
parse_ssa_operands (stmt); parse_ssa_operands (fn, stmt);
/* Now verify the built operands are the same as present in STMT. */ /* Now verify the built operands are the same as present in STMT. */
def = gimple_vdef (stmt); def = gimple_vdef (stmt);
@ -1059,7 +1065,7 @@ verify_ssa_operands (gimple stmt)
the stmt operand lists. */ the stmt operand lists. */
void void
free_stmt_operands (gimple stmt) free_stmt_operands (struct function *fn, gimple stmt)
{ {
use_optype_p uses = gimple_use_ops (stmt), last_use; use_optype_p uses = gimple_use_ops (stmt), last_use;
@ -1068,8 +1074,8 @@ free_stmt_operands (gimple stmt)
for (last_use = uses; last_use->next; last_use = last_use->next) for (last_use = uses; last_use->next; last_use = last_use->next)
delink_imm_use (USE_OP_PTR (last_use)); delink_imm_use (USE_OP_PTR (last_use));
delink_imm_use (USE_OP_PTR (last_use)); delink_imm_use (USE_OP_PTR (last_use));
last_use->next = gimple_ssa_operands (cfun)->free_uses; last_use->next = gimple_ssa_operands (fn)->free_uses;
gimple_ssa_operands (cfun)->free_uses = uses; gimple_ssa_operands (fn)->free_uses = uses;
gimple_set_use_ops (stmt, NULL); gimple_set_use_ops (stmt, NULL);
} }
@ -1084,11 +1090,11 @@ free_stmt_operands (gimple stmt)
/* Get the operands of statement STMT. */ /* Get the operands of statement STMT. */
void void
update_stmt_operands (gimple stmt) update_stmt_operands (struct function *fn, gimple stmt)
{ {
/* If update_stmt_operands is called before SSA is initialized, do /* If update_stmt_operands is called before SSA is initialized, do
nothing. */ nothing. */
if (!ssa_operands_active (cfun)) if (!ssa_operands_active (fn))
return; return;
timevar_push (TV_TREE_OPS); timevar_push (TV_TREE_OPS);
@ -1097,10 +1103,10 @@ update_stmt_operands (gimple stmt)
split_bbs_on_noreturn_calls during cfg cleanup. */ split_bbs_on_noreturn_calls during cfg cleanup. */
if (is_gimple_call (stmt) if (is_gimple_call (stmt)
&& gimple_call_noreturn_p (stmt)) && gimple_call_noreturn_p (stmt))
vec_safe_push (MODIFIED_NORETURN_CALLS (cfun), stmt); vec_safe_push (MODIFIED_NORETURN_CALLS (fn), stmt);
gcc_assert (gimple_modified_p (stmt)); gcc_assert (gimple_modified_p (stmt));
build_ssa_operands (stmt); build_ssa_operands (fn, stmt);
gimple_set_modified (stmt, false); gimple_set_modified (stmt, false);
timevar_pop (TV_TREE_OPS); timevar_pop (TV_TREE_OPS);
@ -1117,8 +1123,6 @@ swap_ssa_operands (gimple stmt, tree *exp0, tree *exp1)
op0 = *exp0; op0 = *exp0;
op1 = *exp1; op1 = *exp1;
gcc_checking_assert (ssa_operands_active (cfun));
if (op0 != op1) if (op0 != op1)
{ {
/* Attempt to preserve the relative positions of these two operands in /* Attempt to preserve the relative positions of these two operands in

View File

@ -91,10 +91,10 @@ struct GTY(()) ssa_operands {
extern bool ssa_operands_active (struct function *); extern bool ssa_operands_active (struct function *);
extern void init_ssa_operands (struct function *fn); extern void init_ssa_operands (struct function *fn);
extern void fini_ssa_operands (void); extern void fini_ssa_operands (struct function *);
extern bool verify_ssa_operands (gimple stmt); extern bool verify_ssa_operands (struct function *, gimple stmt);
extern void free_stmt_operands (gimple); extern void free_stmt_operands (struct function *, gimple);
extern void update_stmt_operands (gimple); extern void update_stmt_operands (struct function *, gimple);
extern void swap_ssa_operands (gimple, tree *, tree *); extern void swap_ssa_operands (gimple, tree *, tree *);
extern bool verify_imm_links (FILE *f, tree var); extern bool verify_imm_links (FILE *f, tree var);

View File

@ -1042,7 +1042,7 @@ verify_ssa (bool check_modified_stmt)
goto err; goto err;
} }
if (verify_ssa_operands (stmt)) if (verify_ssa_operands (cfun, stmt))
{ {
print_gimple_stmt (stderr, stmt, 0, TDF_VOPS); print_gimple_stmt (stderr, stmt, 0, TDF_VOPS);
goto err; goto err;
@ -1195,7 +1195,7 @@ delete_tree_ssa (void)
/* We no longer maintain the SSA operand cache at this point. */ /* We no longer maintain the SSA operand cache at this point. */
if (ssa_operands_active (cfun)) if (ssa_operands_active (cfun))
fini_ssa_operands (); fini_ssa_operands (cfun);
htab_delete (cfun->gimple_df->default_defs); htab_delete (cfun->gimple_df->default_defs);
cfun->gimple_df->default_defs = NULL; cfun->gimple_df->default_defs = NULL;

View File

@ -301,7 +301,7 @@ get_nonzero_bits (const_tree name)
other fields must be assumed clobbered. */ other fields must be assumed clobbered. */
void void
release_ssa_name (tree var) release_ssa_name_fn (struct function *fn, tree var)
{ {
if (!var) if (!var)
return; return;
@ -341,7 +341,7 @@ release_ssa_name (tree var)
while (imm->next != imm) while (imm->next != imm)
delink_imm_use (imm->next); delink_imm_use (imm->next);
(*SSANAMES (cfun))[SSA_NAME_VERSION (var)] = NULL_TREE; (*SSANAMES (fn))[SSA_NAME_VERSION (var)] = NULL_TREE;
memset (var, 0, tree_size (var)); memset (var, 0, tree_size (var));
imm->prev = imm; imm->prev = imm;
@ -363,7 +363,7 @@ release_ssa_name (tree var)
SSA_NAME_IN_FREE_LIST (var) = 1; SSA_NAME_IN_FREE_LIST (var) = 1;
/* And finally put it on the free list. */ /* And finally put it on the free list. */
vec_safe_push (FREE_SSANAMES (cfun), var); vec_safe_push (FREE_SSANAMES (fn), var);
} }
} }

View File

@ -81,7 +81,7 @@ extern void init_ssanames (struct function *, int);
extern void fini_ssanames (void); extern void fini_ssanames (void);
extern void ssanames_print_statistics (void); extern void ssanames_print_statistics (void);
extern tree make_ssa_name_fn (struct function *, tree, gimple); extern tree make_ssa_name_fn (struct function *, tree, gimple);
extern void release_ssa_name (tree); extern void release_ssa_name_fn (struct function *, tree);
extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *, extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *,
unsigned int *); unsigned int *);
extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *); extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *);
@ -127,6 +127,14 @@ duplicate_ssa_name (tree var, gimple stmt)
return duplicate_ssa_name_fn (cfun, var, stmt); return duplicate_ssa_name_fn (cfun, var, stmt);
} }
/* Release the SSA name NAME used in function cfun. */
static inline void
release_ssa_name (tree name)
{
release_ssa_name_fn (cfun, name);
}
/* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT /* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
in function cfun. Arrange so that it uses NAME in dumps. */ in function cfun. Arrange so that it uses NAME in dumps. */