Commit 35b6fdcf by Frank Ch. Eigler Committed by Frank Ch. Eigler

* Fix for g++/15861

2004-07-15  Frank Ch. Eigler  <fche@redhat.com>

	g++/15861
	* cgraphunit.c (cgraph_build_static_cdtor): Add priority argument.
	* cgraph.h: Update declaration.
	* c-decl.c (build_cdtor): Update call with default priority.
	* coverage.c (create_coverage): Ditto.
	* tree-mudflap.c (mf_init_fndecl): New tree.
	(mudflap_init): Set it.
	(mudflap_register_call): Arrange to call __mf_init before the first
	__mf_register call.
	(mudflap_finish_file): Mark the mudflap static initializer as extra
	high priority, to beat all C++ static constructors.

2004-07-15  Frank Ch. Eigler  <fche@redhat.com>

	g++/15861
	* jcf-parse.c (java_emit_static_constructor): Specify default
	priority.

From-SVN: r84760
parent 3e4035f8
2004-07-15 Frank Ch. Eigler <fche@redhat.com>
g++/15861
* cgraphunit.c (cgraph_build_static_cdtor): Add priority argument.
* cgraph.h: Update declaration.
* c-decl.c (build_cdtor): Update call with default priority.
* coverage.c (create_coverage): Ditto.
* tree-mudflap.c (mf_init_fndecl): New tree.
(mudflap_init): Set it.
(mudflap_register_call): Arrange to call __mf_init before the first
__mf_register call.
(mudflap_finish_file): Mark the mudflap static initializer as extra
high priority, to beat all C++ static constructors.
2004-07-15 Jeff Law <law@redhat.com> 2004-07-15 Jeff Law <law@redhat.com>
* loop.c (check_insn_for_givs): Restore check for code labels that was * loop.c (check_insn_for_givs): Restore check for code labels that was
......
...@@ -6616,7 +6616,7 @@ build_cdtor (int method_type, tree cdtors) ...@@ -6616,7 +6616,7 @@ build_cdtor (int method_type, tree cdtors)
append_to_statement_list (build_function_call (TREE_VALUE (cdtors), 0), append_to_statement_list (build_function_call (TREE_VALUE (cdtors), 0),
&body); &body);
cgraph_build_static_cdtor (method_type, body); cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY);
} }
/* Perform final processing on one file scope's declarations (or the /* Perform final processing on one file scope's declarations (or the
......
...@@ -192,6 +192,6 @@ void verify_cgraph (void); ...@@ -192,6 +192,6 @@ void verify_cgraph (void);
void verify_cgraph_node (struct cgraph_node *); void verify_cgraph_node (struct cgraph_node *);
void cgraph_mark_inline_edge (struct cgraph_edge *e); void cgraph_mark_inline_edge (struct cgraph_edge *e);
void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate); void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
void cgraph_build_static_cdtor (char which, tree body); void cgraph_build_static_cdtor (char which, tree body, int priority);
#endif /* GCC_CGRAPH_H */ #endif /* GCC_CGRAPH_H */
...@@ -1792,7 +1792,7 @@ cgraph_optimize (void) ...@@ -1792,7 +1792,7 @@ cgraph_optimize (void)
GENERIC statements. */ GENERIC statements. */
void void
cgraph_build_static_cdtor (char which, tree body) cgraph_build_static_cdtor (char which, tree body, int priority)
{ {
static int counter = 0; static int counter = 0;
char which_buf[16]; char which_buf[16];
...@@ -1846,6 +1846,6 @@ cgraph_build_static_cdtor (char which, tree body) ...@@ -1846,6 +1846,6 @@ cgraph_build_static_cdtor (char which, tree body)
fn = targetm.asm_out.constructor; fn = targetm.asm_out.constructor;
else else
fn = targetm.asm_out.destructor; fn = targetm.asm_out.destructor;
fn (XEXP (DECL_RTL (decl), 0), DEFAULT_INIT_PRIORITY); fn (XEXP (DECL_RTL (decl), 0), priority);
} }
} }
...@@ -939,7 +939,7 @@ create_coverage (void) ...@@ -939,7 +939,7 @@ create_coverage (void)
append_to_statement_list (t, &body); append_to_statement_list (t, &body);
/* Generate a constructor to run it. */ /* Generate a constructor to run it. */
cgraph_build_static_cdtor ('I', body); cgraph_build_static_cdtor ('I', body, DEFAULT_INIT_PRIORITY);
} }
/* Perform file-level initialization. Read in data file, generate name /* Perform file-level initialization. Read in data file, generate name
......
2004-07-15 Frank Ch. Eigler <fche@redhat.com>
g++/15861
* jcf-parse.c (java_emit_static_constructor): Specify default
priority.
2004-07-13 Per Bothner <per@bothner.com> 2004-07-13 Per Bothner <per@bothner.com>
* java-tree.h (all_class_filename): Remove useless macro. * java-tree.h (all_class_filename): Remove useless macro.
......
...@@ -887,7 +887,7 @@ java_emit_static_constructor (void) ...@@ -887,7 +887,7 @@ java_emit_static_constructor (void)
write_resource_constructor (&body); write_resource_constructor (&body);
if (body) if (body)
cgraph_build_static_cdtor ('I', body); cgraph_build_static_cdtor ('I', body, DEFAULT_INIT_PRIORITY);
} }
void void
......
...@@ -268,6 +268,9 @@ static GTY (()) tree mf_register_fndecl; ...@@ -268,6 +268,9 @@ static GTY (()) tree mf_register_fndecl;
/* extern void __mf_unregister (void *ptr, size_t sz, int type); */ /* extern void __mf_unregister (void *ptr, size_t sz, int type); */
static GTY (()) tree mf_unregister_fndecl; static GTY (()) tree mf_unregister_fndecl;
/* extern void __mf_init (); */
static GTY (()) tree mf_init_fndecl;
/* Helper for mudflap_init: construct a decl with the given category, /* Helper for mudflap_init: construct a decl with the given category,
name, and type, mark it an external reference, and pushdecl it. */ name, and type, mark it an external reference, and pushdecl it. */
static inline tree static inline tree
...@@ -303,6 +306,8 @@ mf_make_mf_cache_struct_type (tree field_type) ...@@ -303,6 +306,8 @@ mf_make_mf_cache_struct_type (tree field_type)
return struct_type; return struct_type;
} }
#define build_function_type_0(rtype) \
build_function_type (rtype, void_list_node)
#define build_function_type_3(rtype, arg1, arg2, arg3) \ #define build_function_type_3(rtype, arg1, arg2, arg3) \
build_function_type (rtype, tree_cons (0, arg1, tree_cons (0, arg2, \ build_function_type (rtype, tree_cons (0, arg1, tree_cons (0, arg2, \
tree_cons (0, arg3, void_list_node)))) tree_cons (0, arg3, void_list_node))))
...@@ -321,6 +326,7 @@ mudflap_init (void) ...@@ -321,6 +326,7 @@ mudflap_init (void)
tree mf_cache_array_type; tree mf_cache_array_type;
tree mf_check_register_fntype; tree mf_check_register_fntype;
tree mf_unregister_fntype; tree mf_unregister_fntype;
tree mf_init_fntype;
if (done) if (done)
return; return;
...@@ -341,6 +347,8 @@ mudflap_init (void) ...@@ -341,6 +347,8 @@ mudflap_init (void)
mf_unregister_fntype = mf_unregister_fntype =
build_function_type_3 (void_type_node, ptr_type_node, size_type_node, build_function_type_3 (void_type_node, ptr_type_node, size_type_node,
integer_type_node); integer_type_node);
mf_init_fntype =
build_function_type_0 (void_type_node);
mf_cache_array_decl = mf_make_builtin (VAR_DECL, "__mf_lookup_cache", mf_cache_array_decl = mf_make_builtin (VAR_DECL, "__mf_lookup_cache",
mf_cache_array_type); mf_cache_array_type);
...@@ -354,9 +362,12 @@ mudflap_init (void) ...@@ -354,9 +362,12 @@ mudflap_init (void)
mf_check_register_fntype); mf_check_register_fntype);
mf_unregister_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_unregister", mf_unregister_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_unregister",
mf_unregister_fntype); mf_unregister_fntype);
mf_init_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_init",
mf_init_fntype);
} }
#undef build_function_type_4 #undef build_function_type_4
#undef build_function_type_3 #undef build_function_type_3
#undef build_function_type_0
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
...@@ -1130,6 +1141,13 @@ mudflap_register_call (tree obj, tree object_size, tree varname) ...@@ -1130,6 +1141,13 @@ mudflap_register_call (tree obj, tree object_size, tree varname)
call_stmt = build_function_call_expr (mf_register_fndecl, args); call_stmt = build_function_call_expr (mf_register_fndecl, args);
/* Add an initial __mf_init() call to the list of registration calls. */
if (enqueued_call_stmt_chain == NULL_TREE)
{
tree call2_stmt = build_function_call_expr (mf_init_fndecl, NULL_TREE);
append_to_statement_list (call2_stmt, &enqueued_call_stmt_chain);
}
append_to_statement_list (call_stmt, &enqueued_call_stmt_chain); append_to_statement_list (call_stmt, &enqueued_call_stmt_chain);
} }
...@@ -1246,7 +1264,8 @@ mudflap_finish_file (void) ...@@ -1246,7 +1264,8 @@ mudflap_finish_file (void)
if (enqueued_call_stmt_chain) if (enqueued_call_stmt_chain)
{ {
cgraph_build_static_cdtor ('I', enqueued_call_stmt_chain); cgraph_build_static_cdtor ('I', enqueued_call_stmt_chain,
MAX_RESERVED_INIT_PRIORITY-1);
enqueued_call_stmt_chain = 0; enqueued_call_stmt_chain = 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment