This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch to tree-profiling branch to analyze for const and purefunctions and readonly and non addressable static storage.




Jan Hubicka wrote:

This patch has been approved by Jan. This patch has been tested on I686 and Darwin. There is additional one regression failure caused by a test that requires the detection of pure functions at -O1. This patch only preforms that analysis at -O2 or higher. The test will be fixed in a later patch.

This patch also contains fixes that were developed by Jan. This is why the patch has two changelog entries.



What I really meant about these changes is that they should no longer be neccesary for your code on the current tree-profiling branch. They mix two changes - one avoids the early unreachable function removal that is already done bit different way on the branch and the code to remove unrefernced functions that I didn't comitted yet as it is independent optimization and it brings one regression in libstdc++ I need to look into (debug info is referring variable that is dead otherwise).

Also please be bit carefull about the whitespace - changing it just
introduce merge conflicts and noise in pathces that are anoying to cope
with.  I will keep the unreachable patch removal patch on the branch for
time being (the debug info failure don't seem to be that common and
hopefully I will debug it soonish) but I am applying the attached patch
(after testing) that removes the other hack and fixes the accidental
whitespace changes.



Sorry about the whitespace changes. I did not put them in delibertly. I think that they came in because you sent me the patches as inlined mail rather than attachments and white space is added my the mailer when I cut the text out.

Kenny

Thanks for the rest of patch :)
Honza

Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.4.4.18.2.19
diff -c -3 -p -r1.4.4.18.2.19 cgraph.c
*** cgraph.c 3 Dec 2004 03:58:44 -0000 1.4.4.18.2.19
--- cgraph.c 3 Dec 2004 09:18:01 -0000
*************** decide_is_variable_needed (struct cgraph
*** 717,726 ****
if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
{
if (TREE_PUBLIC (decl))
! node->externally_visible = true;
return true;
}
! /* ??? If the assembler name is set by hand, it is possible to assemble
the name later after finalizing the function and the fact is noticed
in assemble_name then. This is arguably a bug. */
--- 717,726 ----
if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
{
if (TREE_PUBLIC (decl))
! node->externally_visible = true;
return true;
}
! /* ??? If the assembler name is set by hand, it is possible to assemble
the name later after finalizing the function and the fact is noticed
in assemble_name then. This is arguably a bug. */
*************** decide_is_variable_needed (struct cgraph
*** 728,753 ****
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
{
if (TREE_PUBLIC (decl))
! node->externally_visible = true;
return true;
}
! /* If we decided it was needed before, but at the time we didn't have
the definition available, then it's still needed. */
if (node->needed)
return true;
! /* Externally visible functions must be output. The exception is
COMDAT functions that must be output only when they are needed. */
if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
return true;
! if (flag_unit_at_a_time)
return false;
! /* If not doing unit at a time, then we'll only defer this function
if its marked for inlining. Otherwise we want to emit it now. */
! /* We want to emit COMDAT variables only when absolutely necessary. */
if (DECL_COMDAT (decl))
return false;
--- 728,753 ----
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
{
if (TREE_PUBLIC (decl))
! node->externally_visible = true;
return true;
}
! /* If we decided it was needed before, but at the time we didn't have
the definition available, then it's still needed. */
if (node->needed)
return true;
! /* Externally visible functions must be output. The exception is
COMDAT functions that must be output only when they are needed. */
if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
return true;
! if (flag_unit_at_a_time)
return false;
! /* If not doing unit at a time, then we'll only defer this function
if its marked for inlining. Otherwise we want to emit it now. */
! /* We want to emit COMDAT variables only when absolutely necessary. */
if (DECL_COMDAT (decl))
return false;
*************** void
*** 758,764 ****
cgraph_varpool_finalize_decl (tree decl)
{
struct cgraph_varpool_node *node = cgraph_varpool_node (decl);
! /* The first declaration of a variable that comes through this function
decides whether it is global (in C, has external linkage)
or local (in C, has internal linkage). So do nothing more
--- 758,764 ----
cgraph_varpool_finalize_decl (tree decl)
{
struct cgraph_varpool_node *node = cgraph_varpool_node (decl);
! /* The first declaration of a variable that comes through this function
decides whether it is global (in C, has external linkage)
or local (in C, has internal linkage). So do nothing more
*************** cgraph_varpool_finalize_decl (tree decl)
*** 766,784 ****
if (node->finalized)
{
if (cgraph_global_info_ready || !flag_unit_at_a_time)
! cgraph_varpool_assemble_pending_decls ();
return;
}
if (node->needed)
cgraph_varpool_enqueue_needed_node (node);
node->finalized = true;
! if (decide_is_variable_needed (node, decl))
cgraph_varpool_mark_needed_node (node);
if (cgraph_global_info_ready || !flag_unit_at_a_time)
cgraph_varpool_assemble_pending_decls ();
}
/* Return true when the DECL can possibly be inlined. */
bool
cgraph_function_possibly_inlined_p (tree decl)
--- 766,785 ----
if (node->finalized)
{
if (cgraph_global_info_ready || !flag_unit_at_a_time)
! cgraph_varpool_assemble_pending_decls ();
return;
}
if (node->needed)
cgraph_varpool_enqueue_needed_node (node);
node->finalized = true;
! if (decide_is_variable_needed (node, decl))
cgraph_varpool_mark_needed_node (node);
if (cgraph_global_info_ready || !flag_unit_at_a_time)
cgraph_varpool_assemble_pending_decls ();
}
+ /* Return true when the DECL can possibly be inlined. */
bool
cgraph_function_possibly_inlined_p (tree decl)
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.1.4.35.2.33
diff -c -3 -p -r1.1.4.35.2.33 cgraphunit.c
*** cgraphunit.c 3 Dec 2004 03:58:45 -0000 1.1.4.35.2.33
--- cgraphunit.c 3 Dec 2004 09:18:02 -0000
*************** cgraph_expand_function (struct cgraph_no
*** 988,1000 ****
}
}
- /* FIXME this needs to be enhanced. If we are compiling a single
- module this returns true if the variable is a module level static,
- but if we are doing whole program compilation, this could return
- true if TREE_PUBLIC is true. */
- /* Return true if the variable T is the right kind of static variable to
- perform compilation unit scope escape analysis. */
- /* Expand all functions that must be output.
Attempt to topologically sort the nodes so function is output when
--- 988,993 ----
*************** cgraph_optimize (void)
*** 1137,1144 ****
cgraph_varpool_assemble_pending_decls ();
return;
}
- cgraph_varpool_analyze_pending_decls ();
- timevar_push (TV_IPA_OPT);
/* Frontend may output common variables after the unit has been finalized.
--- 1130,1135 ----
*************** cgraph_optimize (void)
*** 1188,1216 ****
fprintf (cgraph_dump_file, "\nFinal ");
dump_cgraph (cgraph_dump_file);
}
! /* #ifdef ENABLE_CHECK */
! /* verify_cgraph (); */
! /* Double check that all inline clones are gone and that all ! function bodies have been released from memory. */ ! /* if (flag_unit_at_a_time */
! /* && !dump_enabled_p (TDI_tree_all) */
! /* && !(sorrycount || errorcount)) */
! /* { */
! /* struct cgraph_node *node; */
! /* bool error_found = false; */
! ! /* for (node = cgraph_nodes; node; node = node->next) */
! /* if (node->analyzed */
! /* && (node->global.inlined_to */
! /* || DECL_SAVED_TREE (node->decl))) */
! /* { */
! /* error_found = true; */
! /* dump_cgraph_node (stderr, node); */
! /* } */
! /* if (error_found) */
! /* internal_error ("Nodes with no released memory found."); */
! /* } */
! /* #endif */
}
/* Generate and emit a static constructor or destructor. WHICH must be
--- 1179,1207 ----
fprintf (cgraph_dump_file, "\nFinal ");
dump_cgraph (cgraph_dump_file);
}
! #ifdef ENABLE_CHECKING
! verify_cgraph ();
! /* Double check that all inline clones are gone and that all
! function bodies have been released from memory. */
! if (flag_unit_at_a_time
! && !dump_enabled_p (TDI_tree_all)
! && !(sorrycount || errorcount))
! {
! struct cgraph_node *node;
! bool error_found = false;
! ! for (node = cgraph_nodes; node; node = node->next)
! if (node->analyzed
! && (node->global.inlined_to
! || DECL_SAVED_TREE (node->decl)))
! {
! error_found = true;
! dump_cgraph_node (stderr, node);
! }
! if (error_found)
! internal_error ("Nodes with no released memory found.");
! }
! #endif
}
/* Generate and emit a static constructor or destructor. WHICH must be
Index: ipa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa.c,v
retrieving revision 1.1.2.3
diff -c -3 -p -r1.1.2.3 ipa.c
*** ipa.c 3 Dec 2004 03:58:45 -0000 1.1.2.3
--- ipa.c 3 Dec 2004 09:18:02 -0000
*************** cgraph_remove_unreachable_nodes (bool be
*** 99,105 ****
bool changed = false;
int insns = 0;
- return false;
#ifdef ENABLE_CHECKING
verify_cgraph ();
#endif
--- 99,104 ----




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]