This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ patch] one more missed mark_used
- From: Jan Hubicka <jh at suse dot cz>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Jan Hubicka <jh at suse dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 2 Aug 2003 13:36:45 +0200
- Subject: Re: [C++ patch] one more missed mark_used
- References: <20030730173156.GZ24216@kam.mff.cuni.cz> <1059694982.17539.56.camel@doubledemon.codesourcery.com>
> On Wed, 2003-07-30 at 10:31, Jan Hubicka wrote:
> > Hi,
> > typeinfo is not produced in unit-at-a-time when it is referenced via EH
> > tables only.
>
> How is this getting output when *not* in unit-at-a-time mode?
>
> I'd like to avoid marking it in two separate places.
Hi,
here is updated patch. It removes the update and also adds code to mark
it as referenced once function is scheduled to be output. This is also
needed for unit-at-a-time so dependencies can be resolved before we
actually start assembling.
Sat Aug 2 13:10:44 CEST 2003 Jan Hubicka <jh@suse.cz>
* decl2.c (mark_member_pointers): Rename to...
(mark_member_pointers_and_eh_handlers): ... this one; deal with eh
handlers
(lower_function): Update call.
* except.c (build_eh_type): tinfo is already used.
* semantics.c (finish_handler_params): Mark tinfo as used.
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.655
diff -c -3 -p -r1.655 decl2.c
*** decl2.c 1 Aug 2003 15:05:59 -0000 1.655
--- decl2.c 2 Aug 2003 11:10:33 -0000
*************** generate_ctor_and_dtor_functions_for_pri
*** 2561,2572 ****
/* Callgraph code does not understand the member pointers. Mark the methods
referenced as used. */
static tree
! mark_member_pointers (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
! void *data ATTRIBUTE_UNUSED)
{
if (TREE_CODE (*tp) == PTRMEM_CST
&& TYPE_PTRMEMFUNC_P (TREE_TYPE (*tp)))
cgraph_mark_needed_node (cgraph_node (PTRMEM_CST_MEMBER (*tp)), 1);
return 0;
}
--- 2561,2588 ----
/* Callgraph code does not understand the member pointers. Mark the methods
referenced as used. */
static tree
! mark_member_pointers_and_eh_handlers (tree *tp,
! int *walk_subtrees,
! void *data ATTRIBUTE_UNUSED)
{
+ /* Avoid useless walking of complex type and declaration nodes. */
+ if (TYPE_P (*tp) || DECL_P (*tp))
+ {
+ *walk_subtrees = 0;
+ return 0;
+ }
if (TREE_CODE (*tp) == PTRMEM_CST
&& TYPE_PTRMEMFUNC_P (TREE_TYPE (*tp)))
cgraph_mark_needed_node (cgraph_node (PTRMEM_CST_MEMBER (*tp)), 1);
+
+ /* EH handlers will emit EH tables referencing typeinfo. */
+ if (TREE_CODE (*tp) == HANDLER
+ && HANDLER_TYPE (*tp))
+ {
+ tree tinfo = get_tinfo_decl (HANDLER_TYPE (*tp));
+
+ cgraph_varpool_mark_needed_node (cgraph_varpool_node (tinfo));
+ }
return 0;
}
*************** mark_member_pointers (tree *tp, int *wal
*** 2575,2581 ****
void
lower_function (tree fn)
{
! walk_tree_without_duplicates (&DECL_SAVED_TREE (fn), mark_member_pointers,
NULL);
}
--- 2591,2598 ----
void
lower_function (tree fn)
{
! walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
! mark_member_pointers_and_eh_handlers,
NULL);
}
Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/except.c,v
retrieving revision 1.157
diff -c -3 -p -r1.157 except.c
*** except.c 8 Jul 2003 01:38:44 -0000 1.157
--- except.c 2 Aug 2003 11:10:33 -0000
*************** build_eh_type_type (tree type)
*** 131,137 ****
else
exp = get_tinfo_decl (type);
- mark_used (exp);
exp = build1 (ADDR_EXPR, ptr_type_node, exp);
return exp;
--- 131,136 ----
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.343
diff -c -3 -p -r1.343 semantics.c
*** semantics.c 2 Aug 2003 11:01:38 -0000 1.343
--- semantics.c 2 Aug 2003 11:10:33 -0000
*************** finish_handler_parms (tree decl, tree ha
*** 956,961 ****
--- 956,966 ----
type = expand_start_catch_block (decl);
HANDLER_TYPE (handler) = type;
+ if (type)
+ {
+ tree tinfo = get_tinfo_decl (type);
+ mark_used (tinfo);
+ }
}
/* Finish a handler, which may be given by HANDLER. The BLOCKs are