This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Misc minor patches
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 01 Apr 2003 08:20:08 -0700
- Subject: [tree-ssa] Misc minor patches
- Reply-to: law at redhat dot com
Time to flush out the misc changes I've queued up while working on the
C++ CFG bits. Nothing earth shattering here.
First, when compiling C++ codes via a wonderful series of events we
end up diving into a BIND_EXPR and creating a block with no statements.
We then proceed to call last_stmt on the new block, but the block has no
statements at this point. last_stmt returns NULL, which we then pass to
stmt_ends_bb_p. Nothing good happens from this point onward.
--
When compiling C++ code CFUN is often NULL. This may in fact be a bug
in the C++ front-end, but we should at least be tolerant of this situation.
Especially since we only wanted to access cfun to print the function's name.
I also enhanced the dumper to dump more information in EH_FILTER_EXPR nodes.
--
Several of the nodes related to exception handling are not handled by
get_stmt_operands or get_expr_operands. The nice thing is those
functions do not care about the EH nodes in question since they
do not have interesting operands.
--
As has been briefly discussed here we're too dependent on
current_function_decl in the tree-ssa code (and elsewhere). This
patch includes a few minor fixes in this area (but nowhere near enough
to have the compiler tolerate an incorrect setting of current_function_decl.
--
The inliner needs to handle EH_FILTER_EXPRs since they are a control
structure.
* tree-cfg.c (make_blocks): Make sure the BIND_EXPR's subgraph
actually ended in a statement before seeing of the statement should
end a basic block.
* tree-cfg.c (dump_tree_cfg): Avoid crashing when cfun is NULL.
(tree_cfg2dot): Likewise.
* tree-dfa.c (dump_immediate_uses): Likewise.
* tree-pretty-print.c (dump_generic_node): Dump the EH_FILTER_FAILURE
nodes attached to an EH_FILTER_EXPR.
* tree-dfa.c (get_stmt_operands): Add cases for TRY_FINALLY_EXPR,
TRY_CATCH_EXPR, CATCH_EXPR and EH_FILTER_EXPR.
(get_expr_operands): Add case for EXC_PTR_EXPR.
* tree-dfa.c (compute_may_aliases): Accept FNDECL as an argument.
Use FNDECL instead of relying on CURRENT_FUNCTION_DECL.
* tree-flow.h (compute_may_aliases): Update prototype.
* tree-ssa.c (rewrite_into_ssa): Corresponding changes.
* tree-inline.c (expand_calls_inline): Correctly handle EH_FILTER_EXPR.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.66
diff -c -3 -p -r1.1.4.66 tree-cfg.c
*** tree-cfg.c 1 Apr 2003 01:09:13 -0000 1.1.4.66
--- tree-cfg.c 1 Apr 2003 15:02:40 -0000
*************** make_blocks (first_p, next_block_link, p
*** 355,361 ****
/* If we are starting the new block just to work around
iterator limitations, keep track of it. */
! if (!stmt_ends_bb_p (stmt))
cfg_stats.num_failed_bind_expr_merges++;
}
}
--- 355,361 ----
/* If we are starting the new block just to work around
iterator limitations, keep track of it. */
! if (stmt && !stmt_ends_bb_p (stmt))
cfg_stats.num_failed_bind_expr_merges++;
}
}
*************** dump_tree_cfg (file, flags)
*** 1832,1838 ****
if (flags & TDF_DETAILS)
{
fputc ('\n', file);
! fprintf (file, ";; Function %s\n\n", current_function_name);
fprintf (file, ";; \n%d basic blocks, %d edges, last basic block
%d.\n",
n_basic_blocks, n_edges, last_basic_block);
--- 1832,1839 ----
if (flags & TDF_DETAILS)
{
fputc ('\n', file);
! if (cfun)
! fprintf (file, ";; Function %s\n\n", current_function_name);
fprintf (file, ";; \n%d basic blocks, %d edges, last basic block
%d.\n",
n_basic_blocks, n_edges, last_basic_block);
*************** tree_cfg2dot (file)
*** 1940,1946 ****
basic_block bb;
/* Write the file header. */
! fprintf (file, "digraph %s\n{\n", current_function_name);
/* Write blocks and edges. */
for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
--- 1941,1948 ----
basic_block bb;
/* Write the file header. */
! if (cfun)
! fprintf (file, "digraph %s\n{\n", current_function_name);
/* Write blocks and edges. */
for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.92
diff -c -3 -p -r1.1.4.92 tree-dfa.c
*** tree-dfa.c 24 Mar 2003 20:27:57 -0000 1.1.4.92
--- tree-dfa.c 1 Apr 2003 15:02:44 -0000
*************** get_stmt_operands (stmt)
*** 258,263 ****
--- 258,267 ----
case LOOP_EXPR:
case BIND_EXPR:
case CASE_LABEL_EXPR:
+ case TRY_CATCH_EXPR:
+ case TRY_FINALLY_EXPR:
+ case EH_FILTER_EXPR:
+ case CATCH_EXPR:
break;
default:
*************** get_expr_operands (stmt, expr_p, flags,
*** 319,324 ****
--- 323,329 ----
|| class == 'b'
|| code == ADDR_EXPR
|| code == FUNCTION_DECL
+ || code == EXC_PTR_EXPR
|| code == LABEL_DECL)
return;
*************** dump_immediate_uses (file)
*** 1236,1242 ****
basic_block bb;
block_stmt_iterator si;
! fprintf (file, "\nDef-use edges for function %s\n", current_function_name);
FOR_EACH_BB (bb)
{
--- 1241,1248 ----
basic_block bb;
block_stmt_iterator si;
! if (cfun)
! fprintf (file, "\nDef-use edges for function %s\n",
current_function_name);
FOR_EACH_BB (bb)
{
*************** clobber_vars_r (tp, walk_subtrees, data)
*** 1523,1529 ****
(-ftree-points-to), this may compute a much bigger set than necessary. */
void
! compute_may_aliases ()
{
static htab_t vars_found;
static htab_t aliased_objects_found;
--- 1529,1536 ----
(-ftree-points-to), this may compute a much bigger set than necessary. */
void
! compute_may_aliases (fndecl)
! tree fndecl;
{
static htab_t vars_found;
static htab_t aliased_objects_found;
*************** compute_may_aliases ()
*** 1537,1543 ****
have been used to declare VLAs. Those variables will be considered
implicitly live by passes like DCE. FIXME: This is a hack. GIMPLE
should expose VLAs in the code. */
! find_vla_decls (DECL_INITIAL (current_function_decl));
num_aliased_objects = 0;
VARRAY_TREE_INIT (aliased_objects, 20, "aliased_objects");
--- 1544,1550 ----
have been used to declare VLAs. Those variables will be considered
implicitly live by passes like DCE. FIXME: This is a hack. GIMPLE
should expose VLAs in the code. */
! find_vla_decls (DECL_INITIAL (fndecl));
num_aliased_objects = 0;
VARRAY_TREE_INIT (aliased_objects, 20, "aliased_objects");
*************** compute_may_aliases ()
*** 1566,1572 ****
if (flag_tree_points_to != PTA_NONE && num_aliased_objects)
{
timevar_push (TV_TREE_PTA);
! create_alias_vars (current_function_decl);
timevar_pop (TV_TREE_PTA);
}
--- 1573,1579 ----
if (flag_tree_points_to != PTA_NONE && num_aliased_objects)
{
timevar_push (TV_TREE_PTA);
! create_alias_vars (fndecl);
timevar_pop (TV_TREE_PTA);
}
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.66
diff -c -3 -p -r1.1.4.66 tree-flow.h
*** tree-flow.h 1 Apr 2003 01:09:13 -0000 1.1.4.66
--- tree-flow.h 1 Apr 2003 15:02:44 -0000
*************** extern void dump_immediate_uses_for PARA
*** 409,415 ****
extern void debug_immediate_uses_for PARAMS ((tree));
extern void remove_decl PARAMS ((tree));
extern tree *find_decl_location PARAMS ((tree, tree));
! extern void compute_may_aliases PARAMS ((void));
extern void compute_reached_uses PARAMS ((int));
extern void compute_immediate_uses PARAMS ((int));
extern void compute_reaching_defs PARAMS ((int));
--- 409,415 ----
extern void debug_immediate_uses_for PARAMS ((tree));
extern void remove_decl PARAMS ((tree));
extern tree *find_decl_location PARAMS ((tree, tree));
! extern void compute_may_aliases PARAMS ((tree));
extern void compute_reached_uses PARAMS ((int));
extern void compute_immediate_uses PARAMS ((int));
extern void compute_reaching_defs PARAMS ((int));
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26.2.22
diff -c -3 -p -r1.26.2.22 tree-inline.c
*** tree-inline.c 1 Apr 2003 01:09:13 -0000 1.26.2.22
--- tree-inline.c 1 Apr 2003 15:02:47 -0000
*************** expand_calls_inline (tp, id)
*** 1205,1210 ****
--- 1205,1215 ----
/* Dive into the SWITCH_EXPR. */
expand_calls_inline (&CATCH_BODY (*stmt_p), id);
}
+ else if (code == EH_FILTER_EXPR)
+ {
+ /* Dive into the SWITCH_EXPR. */
+ expand_calls_inline (&EH_FILTER_FAILURE (*stmt_p), id);
+ }
else if (code == TRY_CATCH_EXPR || code == TRY_FINALLY_EXPR)
{
/* Dive into TRY_*_EXPRs. */
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.19
diff -c -3 -p -r1.1.2.19 tree-pretty-print.c
*** tree-pretty-print.c 7 Mar 2003 19:26:49 -0000 1.1.2.19
--- tree-pretty-print.c 1 Apr 2003 15:02:49 -0000
*************** dump_generic_node (buffer, node, spc, fl
*** 1059,1064 ****
--- 1059,1070 ----
output_add_string (buffer, "<<<eh_filter (");
dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags);
output_add_string (buffer, ")>>>");
+ newline_and_indent (buffer, spc+2);
+ output_add_string (buffer, "{");
+ newline_and_indent (buffer, spc+4);
+ dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags);
+ newline_and_indent (buffer, spc+2);
+ output_add_string (buffer, "}");
break;
case GOTO_SUBROUTINE_EXPR:
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.60
diff -c -3 -p -r1.1.4.60 tree-ssa.c
*** tree-ssa.c 29 Mar 2003 03:42:32 -0000 1.1.4.60
--- tree-ssa.c 1 Apr 2003 15:02:52 -0000
*************** rewrite_into_ssa (fndecl)
*** 285,291 ****
tree_ssa_dump_file = dump_begin (TDI_ssa, &tree_ssa_dump_flags);
/* Compute aliasing information. */
! compute_may_aliases ();
globals = sbitmap_alloc (num_referenced_vars);
sbitmap_zero (globals);
--- 285,291 ----
tree_ssa_dump_file = dump_begin (TDI_ssa, &tree_ssa_dump_flags);
/* Compute aliasing information. */
! compute_may_aliases (fndecl);
globals = sbitmap_alloc (num_referenced_vars);
sbitmap_zero (globals);