This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[incremental] Patch: FYI: delay gimplification + partial cgraph revert
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 28 Sep 2007 17:15:11 -0600
- Subject: [incremental] Patch: FYI: delay gimplification + partial cgraph revert
- Reply-to: Tom Tromey <tromey at redhat dot com>
I'm checking this in on the incremental-compiler branch.
The cgraph change I made the other day didn't really do that well in
all cases; it ICEd in some inlining scenarios. So rather than
continue down this path I thought it would be better to defer
gimplification until after the server forks for code generation. This
should save memory in the server as well.
This patch is based on a patch that Michael Matz wrote, hence his name
in the ChangeLog. Complain to me if you hate it, though.
The cgraph_finalize_compilation_unit part of this patch will need a
bit of work... some in the other front ends, and then (maybe) some for
--combine.
Though the current patch is flawed, I think this is a good direction
for the compiler to go. It helps to further separate the front and
back ends. Michael pointed out that c_gimple_diagnostics_recursively
needs to be done in an FE-independent way, but from what I can tell
both c_warn_unused_result and diagnose_omp_structured_block_errors are
already language independent.
Tom
ChangeLog:
2007-09-28 Tom Tromey <tromey@redhat.com>
Michael Matz <matz@suse.de>
* c-gimplify.c (c_genericize): Don't call gimplify_function_tree.
(c_gimplify_expr): Handle CALL_EXPR, FDESC_EXPR, and ADDR_EXPR.
* tree-optimize.c (tree_lowering_passes): Call
gimplify_function_tree.
* c-decl.c (pop_file_scope): Don't call
cgraph_finalize_compilation_unit.
(finish_function): Don't call c_gimple_diagnostics_recursively.
* toplev.c (compile_file): Call cgraph_finalize_compilation_unit.
* cgraphunit.c (verify_cgraph_node): Reverted.
* cgraph.h (cgraph_get_callee_fndecl): Removed.
* cgraphbuild.c (build_cgraph_edges): Reverted.
(rebuild_cgraph_edges): Likewise.
* cgraph.c (cgraph_note_duplicate): Clean up.
(cgraph_get_callee_fndecl): Removed.
Index: cgraphbuild.c
===================================================================
--- cgraphbuild.c (revision 128823)
+++ cgraphbuild.c (working copy)
@@ -130,7 +130,7 @@
tree call = get_call_expr_in (stmt);
tree decl;
- if (call && (decl = cgraph_get_callee_fndecl (call)))
+ if (call && (decl = get_callee_fndecl (call)))
{
int i;
int n = call_expr_nargs (call);
@@ -224,7 +224,7 @@
tree call = get_call_expr_in (stmt);
tree decl;
- if (call && (decl = cgraph_get_callee_fndecl (call)))
+ if (call && (decl = get_callee_fndecl (call)))
{
int freq = (!bb->frequency && !entry_freq ? CGRAPH_FREQ_BASE
: bb->frequency * CGRAPH_FREQ_BASE / entry_freq);
Index: cgraph.c
===================================================================
--- cgraph.c (revision 128823)
+++ cgraph.c (working copy)
@@ -270,33 +270,12 @@
if (!duplicate_map)
duplicate_map = pointer_map_create ();
- /* FIXME: this seems bogus & lame. */
-
- if (DECL_INITIAL (duplicate))
- {
- /* FIXME: shouldn't be able to see a DECL_INITIAL here.
- Something is decl-smashing again. */
- gcc_assert (!DECL_INITIAL (decl)
- || DECL_INITIAL (decl) == DECL_INITIAL (duplicate));
- slot = pointer_map_insert (duplicate_map, decl);
- *slot = duplicate;
- }
- else
- {
- pointer_map_insert (duplicate_map, duplicate);
- *slot = decl;
- }
+ /* Due to the way decl smashing works, the most recent decl is
+ always canonical. */
+ slot = pointer_map_insert (duplicate_map, decl);
+ *slot = duplicate;
}
-/* Like get_callee_fndecl, but returns the canonical target of the
- call. */
-tree
-cgraph_get_callee_fndecl (tree expr)
-{
- tree result = get_callee_fndecl (expr);
- return cgraph_canonical_decl (result);
-}
-
/* Insert already constructed node into hashtable. */
void
Index: cgraph.h
===================================================================
--- cgraph.h (revision 128823)
+++ cgraph.h (working copy)
@@ -290,7 +290,6 @@
void cgraph_reset (void);
void cgraph_note_duplicate (tree, tree);
tree cgraph_canonical_decl (tree);
-tree cgraph_get_callee_fndecl (tree);
void dump_cgraph (FILE *);
void dump_cgraph_node (FILE *, struct cgraph_node *);
void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
Index: toplev.c
===================================================================
--- toplev.c (revision 128735)
+++ toplev.c (working copy)
@@ -1067,6 +1067,8 @@
if (server_mode && server_start_back_end ())
return false;
+ cgraph_finalize_compilation_unit ();
+
lang_hooks.decls.final_write_globals ();
if (errorcount || sorrycount)
Index: cgraphunit.c
===================================================================
--- cgraphunit.c (revision 128823)
+++ cgraphunit.c (working copy)
@@ -689,7 +689,7 @@
tree stmt = bsi_stmt (bsi);
tree call = get_call_expr_in (stmt);
tree decl;
- if (call && (decl = cgraph_get_callee_fndecl (call)))
+ if (call && (decl = get_callee_fndecl (call)))
{
struct cgraph_edge *e = cgraph_edge (node, stmt);
if (e)
Index: c-decl.c
===================================================================
--- c-decl.c (revision 128823)
+++ c-decl.c (working copy)
@@ -983,7 +983,6 @@
file_scope = 0;
maybe_apply_pending_pragma_weaks ();
- cgraph_finalize_compilation_unit ();
}
/* Insert BLOCK at the end of the list of subblocks of the current
@@ -7024,7 +7023,8 @@
if (!decl_function_context (fndecl))
{
c_genericize (fndecl);
- c_gimple_diagnostics_recursively (fndecl);
+ /* FIXME: this should be a generic pass. */
+/* c_gimple_diagnostics_recursively (fndecl); */
/* ??? Objc emits functions after finalizing the compilation unit.
This should be cleaned up later and this conditional removed. */
Index: tree-optimize.c
===================================================================
--- tree-optimize.c (revision 127650)
+++ tree-optimize.c (working copy)
@@ -355,6 +355,7 @@
current_function_decl = fn;
push_cfun (DECL_STRUCT_FUNCTION (fn));
tree_register_cfg_hooks ();
+ gimplify_function_tree (fn);
bitmap_obstack_initialize (NULL);
execute_pass_list (all_lowering_passes);
if (optimize && cgraph_global_info_ready)
Index: c-gimplify.c
===================================================================
--- c-gimplify.c (revision 127650)
+++ c-gimplify.c (working copy)
@@ -101,9 +101,6 @@
dump_end (TDI_original, dump_orig);
}
- /* Go ahead and gimplify for now. */
- gimplify_function_tree (fndecl);
-
/* Dump the genericized tree IR. */
dump_function (TDI_generic, fndecl);
@@ -230,6 +227,23 @@
TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1;
return GS_UNHANDLED;
+ case CALL_EXPR:
+ {
+ tree callee = TREE_OPERAND (*expr_p, 1);
+ if (TREE_CODE (callee) == FUNCTION_DECL)
+ TREE_OPERAND (*expr_p, 1) = cgraph_canonical_decl (callee);
+ }
+ return GS_UNHANDLED;
+
+ case FDESC_EXPR:
+ case ADDR_EXPR:
+ {
+ tree decl = TREE_OPERAND (*expr_p, 0);
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ TREE_OPERAND (*expr_p, 0) = cgraph_canonical_decl (decl);
+ }
+ return GS_UNHANDLED;
+
case COMPOUND_LITERAL_EXPR:
return gimplify_compound_literal_expr (expr_p, pre_p);