Commit 3a9ed12a by Jan Hubicka Committed by Jan Hubicka

This time really commit PR middle-end/45388

This time really commit
	PR middle-end/45388
	* decl2.c (start_objects): Do not generate collect2 recognicable name
	for static ctor.
	* ipa.c (cgraph_build_static_cdtor_1): Break out from ... ; add FINAL parameter.
	(cgraph_build_static_cdtor): ... here.
	(build_cdtor): Use cgraph_build_static_cdtor_1.

From-SVN: r167781
parent 24b00560
2010-12-13 Jan Hubicka <jh@suse.cz>
PR middle-end/45388
* ipa.c (cgraph_build_static_cdtor_1): Break out from ... ; add FINAL parameter.
(cgraph_build_static_cdtor): ... here.
(build_cdtor): Use cgraph_build_static_cdtor_1.
2010-12-13 Joseph Myers <joseph@codesourcery.com> 2010-12-13 Joseph Myers <joseph@codesourcery.com>
* config/m32c/m32c.h (ENDFILE_SPEC, LINK_SPEC, SIZE_TYPE, * config/m32c/m32c.h (ENDFILE_SPEC, LINK_SPEC, SIZE_TYPE,
...@@ -52,13 +59,6 @@ ...@@ -52,13 +59,6 @@
(emit_note_insn_var_location): Remove ENABLE_RTL_CHECKING verification. (emit_note_insn_var_location): Remove ENABLE_RTL_CHECKING verification.
(vt_emit_notes): Don't initialize and destroy emitted_notes. (vt_emit_notes): Don't initialize and destroy emitted_notes.
2010-12-13 Jan Hubicka <jh@suse.cz>
PR middle-end/45388
* ipa.c (cgraph_build_static_cdtor_1): Break out from ... ; add FINAL parameter.
(cgraph_build_static_cdtor): ... here.
(build_cdtor): Use cgraph_build_static_cdtor_1.
2010-12-13 Nathan Froyd <froydnj@codesourcery.com> 2010-12-13 Nathan Froyd <froydnj@codesourcery.com>
PR target/46040 PR target/46040
...@@ -2691,7 +2691,7 @@ start_objects (int method_type, int initp) ...@@ -2691,7 +2691,7 @@ start_objects (int method_type, int initp)
{ {
tree body; tree body;
tree fndecl; tree fndecl;
char type[10]; char type[14];
/* Make ctor or dtor function. METHOD_TYPE may be 'I' or 'D'. */ /* Make ctor or dtor function. METHOD_TYPE may be 'I' or 'D'. */
...@@ -2705,10 +2705,10 @@ start_objects (int method_type, int initp) ...@@ -2705,10 +2705,10 @@ start_objects (int method_type, int initp)
joiner = '_'; joiner = '_';
#endif #endif
sprintf (type, "%c%c%.5u", method_type, joiner, initp); sprintf (type, "sub_%c%c%.5u", method_type, joiner, initp);
} }
else else
sprintf (type, "%c", method_type); sprintf (type, "sub_%c", method_type);
fndecl = build_lang_decl (FUNCTION_DECL, fndecl = build_lang_decl (FUNCTION_DECL,
get_file_function_name (type), get_file_function_name (type),
......
...@@ -1496,10 +1496,13 @@ struct ipa_opt_pass_d pass_ipa_profile = ...@@ -1496,10 +1496,13 @@ struct ipa_opt_pass_d pass_ipa_profile =
/* Generate and emit a static constructor or destructor. WHICH must /* Generate and emit a static constructor or destructor. WHICH must
be one of 'I' (for a constructor) or 'D' (for a destructor). BODY be one of 'I' (for a constructor) or 'D' (for a destructor). BODY
is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the
initialization priority for this constructor or destructor. */ initialization priority for this constructor or destructor.
void FINAL specify whether the externally visible name for collect2 should
cgraph_build_static_cdtor (char which, tree body, int priority) be produced. */
static void
cgraph_build_static_cdtor_1 (char which, tree body, int priority, bool final)
{ {
static int counter = 0; static int counter = 0;
char which_buf[16]; char which_buf[16];
...@@ -1508,7 +1511,12 @@ cgraph_build_static_cdtor (char which, tree body, int priority) ...@@ -1508,7 +1511,12 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
/* The priority is encoded in the constructor or destructor name. /* The priority is encoded in the constructor or destructor name.
collect2 will sort the names and arrange that they are called at collect2 will sort the names and arrange that they are called at
program startup. */ program startup. */
sprintf (which_buf, "%c_%.5d_%d", which, priority, counter++); if (final)
sprintf (which_buf, "%c_%.5d_%d", which, priority, counter++);
else
/* Proudce sane name but one not recognizable by collect2, just for the
case we fail to inline the function. */
sprintf (which_buf, "sub_%c_%.5d_%d", which, priority, counter++);
name = get_file_function_name (which_buf); name = get_file_function_name (which_buf);
decl = build_decl (input_location, FUNCTION_DECL, name, decl = build_decl (input_location, FUNCTION_DECL, name,
...@@ -1528,7 +1536,7 @@ cgraph_build_static_cdtor (char which, tree body, int priority) ...@@ -1528,7 +1536,7 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
DECL_ARTIFICIAL (decl) = 1; DECL_ARTIFICIAL (decl) = 1;
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1; DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
DECL_SAVED_TREE (decl) = body; DECL_SAVED_TREE (decl) = body;
if (!targetm.have_ctors_dtors) if (!targetm.have_ctors_dtors && final)
{ {
TREE_PUBLIC (decl) = 1; TREE_PUBLIC (decl) = 1;
DECL_PRESERVE_P (decl) = 1; DECL_PRESERVE_P (decl) = 1;
...@@ -1563,6 +1571,16 @@ cgraph_build_static_cdtor (char which, tree body, int priority) ...@@ -1563,6 +1571,16 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
current_function_decl = NULL; current_function_decl = NULL;
} }
/* Generate and emit a static constructor or destructor. WHICH must
be one of 'I' (for a constructor) or 'D' (for a destructor). BODY
is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the
initialization priority for this constructor or destructor. */
void
cgraph_build_static_cdtor (char which, tree body, int priority)
{
cgraph_build_static_cdtor_1 (which, body, priority, false);
}
/* A vector of FUNCTION_DECLs declared as static constructors. */ /* A vector of FUNCTION_DECLs declared as static constructors. */
static VEC(tree, heap) *static_ctors; static VEC(tree, heap) *static_ctors;
...@@ -1648,7 +1666,7 @@ build_cdtor (bool ctor_p, VEC (tree, heap) *cdtors) ...@@ -1648,7 +1666,7 @@ build_cdtor (bool ctor_p, VEC (tree, heap) *cdtors)
gcc_assert (body != NULL_TREE); gcc_assert (body != NULL_TREE);
/* Generate a function to call all the function of like /* Generate a function to call all the function of like
priority. */ priority. */
cgraph_build_static_cdtor (ctor_p ? 'I' : 'D', body, priority); cgraph_build_static_cdtor_1 (ctor_p ? 'I' : 'D', body, priority, true);
} }
} }
......
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