* [incremental] Patch: FYI: delay gimplification + partial cgraph revert
@ 2007-09-29 4:11 Tom Tromey
2007-09-29 17:51 ` Diego Novillo
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2007-09-29 4:11 UTC (permalink / raw)
To: Gcc Patch List
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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [incremental] Patch: FYI: delay gimplification + partial cgraph revert
2007-09-29 4:11 [incremental] Patch: FYI: delay gimplification + partial cgraph revert Tom Tromey
@ 2007-09-29 17:51 ` Diego Novillo
2007-09-29 19:26 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Diego Novillo @ 2007-09-29 17:51 UTC (permalink / raw)
To: Tom Tromey; +Cc: Gcc Patch List
On 9/28/07, Tom Tromey <tromey@redhat.com> wrote:
> Though the current patch is flawed, I think this is a good direction
> for the compiler to go.
I agree. Would you consider moving this into mainline when stage1
opens again? Delaying gimplification on the C/C++ FEs is a Good
Thing.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [incremental] Patch: FYI: delay gimplification + partial cgraph revert
2007-09-29 17:51 ` Diego Novillo
@ 2007-09-29 19:26 ` Tom Tromey
2007-09-29 21:30 ` Richard Guenther
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2007-09-29 19:26 UTC (permalink / raw)
To: Diego Novillo; +Cc: Gcc Patch List
>>>>> "Diego" == Diego Novillo <dnovillo@google.com> writes:
Diego> On 9/28/07, Tom Tromey <tromey@redhat.com> wrote:
>> Though the current patch is flawed, I think this is a good direction
>> for the compiler to go.
Diego> I agree. Would you consider moving this into mainline when stage1
Diego> opens again? Delaying gimplification on the C/C++ FEs is a Good
Diego> Thing.
Sure thing. Though perhaps Michael will beat me to it :-)
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [incremental] Patch: FYI: delay gimplification + partial cgraph revert
2007-09-29 19:26 ` Tom Tromey
@ 2007-09-29 21:30 ` Richard Guenther
2007-09-30 11:17 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2007-09-29 21:30 UTC (permalink / raw)
To: tromey; +Cc: Diego Novillo, Gcc Patch List
On 9/29/07, Tom Tromey <tromey@redhat.com> wrote:
> >>>>> "Diego" == Diego Novillo <dnovillo@google.com> writes:
>
> Diego> On 9/28/07, Tom Tromey <tromey@redhat.com> wrote:
> >> Though the current patch is flawed, I think this is a good direction
> >> for the compiler to go.
>
> Diego> I agree. Would you consider moving this into mainline when stage1
> Diego> opens again? Delaying gimplification on the C/C++ FEs is a Good
> Diego> Thing.
>
> Sure thing. Though perhaps Michael will beat me to it :-)
There were concerns about memory usage regressions (it's not clear
whether the un-gimplified or the gimplified variant takes more memory).
Richard.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [incremental] Patch: FYI: delay gimplification + partial cgraph revert
2007-09-29 21:30 ` Richard Guenther
@ 2007-09-30 11:17 ` Tom Tromey
0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2007-09-30 11:17 UTC (permalink / raw)
To: Richard Guenther; +Cc: Diego Novillo, Gcc Patch List
>>>>> "Richard" == Richard Guenther <richard.guenther@gmail.com> writes:
Richard> There were concerns about memory usage regressions (it's not clear
Richard> whether the un-gimplified or the gimplified variant takes more memory).
Thanks. I made a note to look at this.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-29 22:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-29 4:11 [incremental] Patch: FYI: delay gimplification + partial cgraph revert Tom Tromey
2007-09-29 17:51 ` Diego Novillo
2007-09-29 19:26 ` Tom Tromey
2007-09-29 21:30 ` Richard Guenther
2007-09-30 11:17 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).