This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-profiling] Avoid IPA on variables comming late
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 Dec 2004 16:52:15 +0100
- Subject: [tree-profiling] Avoid IPA on variables comming late
Hi,
we do have some variables (such as those used by profiling stuff) that
are constructed late in game and thus we need to hide them behind IPA.
Most common case of these are typeinfos produced by EH machinery. It
seems to me that it would be better to deal with this by emmiting them
early and removing those whose references are optimized out. I have
patch for the second half of problem I will send once testing passes.
Bootstrapped/regtested i686-pc-gnu-linux.
Honza
Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.1.4.16.2.16
diff -c -3 -p -r1.1.4.16.2.16 cgraph.h
*** cgraph.h 30 Nov 2004 17:43:42 -0000 1.1.4.16.2.16
--- cgraph.h 30 Nov 2004 21:11:08 -0000
*************** struct cgraph_varpool_node GTY(())
*** 214,219 ****
--- 210,219 ----
bool output;
/* Set when function is visible by other units. */
bool externally_visible;
+ /* Some datastructures (such as typeinfos for EH handling) can be output
+ late during the RTL compilation. We need to make these invisible to
+ IPA optimizers or we confuse them badly. */
+ bool non_ipa;
};
extern GTY(()) struct cgraph_node *cgraph_nodes;
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.1.4.35.2.30
diff -c -3 -p -r1.1.4.35.2.30 cgraphunit.c
*** cgraphunit.c 30 Nov 2004 17:43:42 -0000 1.1.4.35.2.30
--- cgraphunit.c 30 Nov 2004 21:11:08 -0000
*************** cgraph_varpool_analyze_pending_decls (vo
*** 715,721 ****
tree decl = cgraph_varpool_first_unanalyzed_node->decl;
cgraph_varpool_first_unanalyzed_node->analyzed = true;
! ipa_analyze_variable (cgraph_varpool_first_unanalyzed_node);
cgraph_varpool_first_unanalyzed_node = cgraph_varpool_first_unanalyzed_node->next_needed;
if (DECL_INITIAL (decl))
cgraph_create_edges (NULL, DECL_INITIAL (decl));
--- 715,728 ----
tree decl = cgraph_varpool_first_unanalyzed_node->decl;
cgraph_varpool_first_unanalyzed_node->analyzed = true;
!
! /* Some datastructures (such as typeinfos for EH handling) can be output
! late during the RTL compilation. We need to make these invisible to
! IPA optimizers or we confuse them badly. */
! if (!cgraph_global_info_ready)
! ipa_analyze_variable (cgraph_varpool_first_unanalyzed_node);
! else
! cgraph_varpool_first_unanalyzed_node->non_ipa = true;
cgraph_varpool_first_unanalyzed_node = cgraph_varpool_first_unanalyzed_node->next_needed;
if (DECL_INITIAL (decl))
cgraph_create_edges (NULL, DECL_INITIAL (decl));
*************** cgraph_varpool_assemble_pending_decls (v
*** 747,753 ****
cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
if (!TREE_ASM_WRITTEN (decl) && !DECL_EXTERNAL (decl))
{
! ipa_modify_variable (node);
assemble_variable (decl, 0, 1, 0);
changed = true;
}
--- 754,761 ----
cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
if (!TREE_ASM_WRITTEN (decl) && !DECL_EXTERNAL (decl))
{
! if (!node->non_ipa)
! ipa_modify_variable (node);
assemble_variable (decl, 0, 1, 0);
changed = true;
}
*************** cgraph_optimize (void)
*** 1123,1128 ****
--- 1131,1140 ----
}
timevar_push (TV_IPA_OPT);
+ /* Frontend may output common variables after the unit has been finalized.
+ It is safe to deal with them here as they are always zero initialized. */
+ cgraph_varpool_analyze_pending_decls ();
+
cgraph_function_and_variable_visibility ();
if (flag_ipa_cp && flag_ipa_no_cloning)
Index: ipa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa.c,v
retrieving revision 1.1.2.1
diff -c -3 -p -r1.1.2.1 ipa.c
*** ipa.c 30 Nov 2004 17:43:43 -0000 1.1.2.1
--- ipa.c 30 Nov 2004 21:11:08 -0000
*************** cgraph_remove_unreachable_nodes (bool be
*** 186,191 ****
--- 186,192 ----
DECL_SAVED_TREE (node->decl) = NULL;
DECL_STRUCT_FUNCTION (node->decl) = NULL;
DECL_INITIAL (node->decl) = error_mark_node;
+ node->analyzed = false;
}
while (node->callees)
cgraph_remove_edge (node->callees);