* semantics.c (expand_or_defer_fn): Do not call c_record_cdtor_fn.
* decl2.c (start_objects): ctors and dtors are no longer public.
(cp_write_global_declarations): Do not call c_build_cdtor_fns.
* cgraphunit.c: Include gt-cgraphunit.h
(static_ctors, static_dtors): New static vars.
(record_cdtor_fn, build_cdtor, cgraph_build_cdtor_fns): New functions,
based on implementation in c-common.c
(cgraph_finalize_function): Call record_cdtor_fn.
(cgraph_optimize): Call cgraph_build_cdtor_fns.
* decl.c (finish_function): Do not call c_record_cdtor_fn.
(c_write_global_declarations): Do not call c_build_cdtor_fns.
* c-common.c (static_ctors, static_dtors, c_record_cdtor_fn,
build_cdtor, c_build_cdtor_fns): Remove.
* c-common.h (static_ctors, static_dtors, c_record_cdtor_fn,
c_build_cdtor_fns): Remove prototype.
From-SVN: r124618
+2007-05-11 Jan Hubicka <jh@suse.cz>
+
+ * cgraphunit.c: Include gt-cgraphunit.h
+ (static_ctors, static_dtors): New static vars.
+ (record_cdtor_fn, build_cdtor, cgraph_build_cdtor_fns): New functions,
+ based on implementation in c-common.c
+ (cgraph_finalize_function): Call record_cdtor_fn.
+ (cgraph_optimize): Call cgraph_build_cdtor_fns.
+ * decl.c (finish_function): Do not call c_record_cdtor_fn.
+ (c_write_global_declarations): Do not call c_build_cdtor_fns.
+ * c-common.c (static_ctors, static_dtors, c_record_cdtor_fn,
+ build_cdtor, c_build_cdtor_fns): Remove.
+ * c-common.h (static_ctors, static_dtors, c_record_cdtor_fn,
+ c_build_cdtor_fns): Remove prototype.
+
2007-05-11 Paolo Carlini <pcarlini@suse.de>
PR other/31852
$(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(FLAGS_H) $(GGC_H) \
$(TARGET_H) $(CGRAPH_H) intl.h pointer-set.h $(FUNCTION_H) $(TREE_GIMPLE_H) \
$(TREE_FLOW_H) tree-pass.h $(C_COMMON_H) debug.h $(DIAGNOSTIC_H) \
- $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) ipa-prop.h
+ $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) ipa-prop.h \
+ gt-cgraphunit.h
cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(TREE_GIMPLE_H) \
$(TREE_FLOW_H) tree-pass.h
$(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
$(srcdir)/tree-ssa-structalias.c \
$(srcdir)/omp-low.c $(srcdir)/varpool.c \
- $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c \
+ $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c \
@all_gtfiles@
GTFILES_H = $(subst /,-, $(subst $(srcdir)/,gt-, $(subst .c,.h, \
{ NULL, 0, 0, false, false, false, NULL }
};
-/* Functions called automatically at the beginning and end of execution. */
-
-tree static_ctors;
-tree static_dtors;
-
/* Push current bindings for the function name VAR_DECLS. */
void
}
}
-/* If FNDECL is a static constructor or destructor, add it to the list
- of functions to be called by the file scope initialization
- function. */
-
-void
-c_record_cdtor_fn (tree fndecl)
-{
- if (targetm.have_ctors_dtors)
- return;
-
- if (DECL_STATIC_CONSTRUCTOR (fndecl))
- static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
- if (DECL_STATIC_DESTRUCTOR (fndecl))
- static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
-}
-
-/* Synthesize a function which calls all the global ctors or global
- dtors in this file. This is only used for targets which do not
- support .ctors/.dtors sections. FIXME: Migrate into cgraph. */
-static void
-build_cdtor (int method_type, tree cdtors)
-{
- tree body = 0;
-
- if (!cdtors)
- return;
-
- for (; cdtors; cdtors = TREE_CHAIN (cdtors))
- append_to_statement_list (build_function_call (TREE_VALUE (cdtors), 0),
- &body);
-
- cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY);
-}
-
-/* Generate functions to call static constructors and destructors
- for targets that do not support .ctors/.dtors sections. These
- functions have magic names which are detected by collect2. */
-
-void
-c_build_cdtor_fns (void)
-{
- if (!targetm.have_ctors_dtors)
- {
- build_cdtor ('I', static_ctors);
- static_ctors = NULL_TREE;
- build_cdtor ('D', static_dtors);
- static_dtors = NULL_TREE;
- }
- else
- {
- gcc_assert (!static_ctors);
- gcc_assert (!static_dtors);
- }
-}
-
#ifndef TARGET_HAS_TARGETCM
struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
#endif
#define GCC_DIAG_STYLE __gcc_cdiag__
#endif
-/* Functions called automatically at the beginning and end of execution. */
-extern GTY (()) tree static_ctors;
-extern GTY (()) tree static_dtors;
-
-extern void c_record_cdtor_fn (tree);
-extern void c_build_cdtor_fns (void);
-
#endif /* ! GCC_C_COMMON_H */
info for the epilogue. */
cfun->function_end_locus = input_location;
- /* Keep track of functions declared with the "constructor" and
- "destructor" attribute. */
- c_record_cdtor_fn (fndecl);
-
/* Finalize the ELF visibility for the function. */
c_determine_visibility (fndecl);
c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
c_write_global_declarations_1 (BLOCK_VARS (ext_block));
- /* Call functions declared with the "constructor" or "destructor"
- attribute. */
- c_build_cdtor_fns ();
-
/* We're done parsing; proceed to optimize and emit assembly.
FIXME: shouldn't be the front end's responsibility to call this. */
cgraph_optimize ();
static FILE *cgraph_dump_file;
+static GTY (()) tree static_ctors;
+static GTY (()) tree static_dtors;
+
+/* When target does not have ctors and dtors, we call all constructor
+ and destructor by special initialization/destruction functio
+ recognized by collect2.
+
+ When we are going to build this function, collect all constructors and
+ destructors and turn them into normal functions. */
+
+static void
+record_cdtor_fn (tree fndecl)
+{
+ if (targetm.have_ctors_dtors)
+ return;
+
+ if (DECL_STATIC_CONSTRUCTOR (fndecl))
+ {
+ static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
+ DECL_STATIC_CONSTRUCTOR (fndecl) = 0;
+ cgraph_mark_reachable_node (cgraph_node (fndecl));
+ }
+ if (DECL_STATIC_DESTRUCTOR (fndecl))
+ {
+ static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
+ DECL_STATIC_DESTRUCTOR (fndecl) = 0;
+ cgraph_mark_reachable_node (cgraph_node (fndecl));
+ }
+}
+
+/* Synthesize a function which calls all the global ctors or global
+ dtors in this file. This is only used for targets which do not
+ support .ctors/.dtors sections. */
+static void
+build_cdtor (int method_type, tree cdtors)
+{
+ tree body = 0;
+
+ if (!cdtors)
+ return;
+
+ for (; cdtors; cdtors = TREE_CHAIN (cdtors))
+ append_to_statement_list (build_function_call_expr (TREE_VALUE (cdtors), 0),
+ &body);
+
+ cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY);
+}
+
+/* Generate functions to call static constructors and destructors
+ for targets that do not support .ctors/.dtors sections. These
+ functions have magic names which are detected by collect2. */
+
+static void
+cgraph_build_cdtor_fns (void)
+{
+ if (!targetm.have_ctors_dtors)
+ {
+ build_cdtor ('I', static_ctors);
+ static_ctors = NULL_TREE;
+ build_cdtor ('D', static_dtors);
+ static_dtors = NULL_TREE;
+ }
+ else
+ {
+ gcc_assert (!static_ctors);
+ gcc_assert (!static_dtors);
+ }
+}
+
/* Determine if function DECL is needed. That is, visible to something
either outside this translation unit, something magic in the system
configury, or (if not doing unit-at-a-time) to something we havn't
node->decl = decl;
node->local.finalized = true;
node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
+ record_cdtor_fn (node->decl);
if (node->nested)
lower_nested_functions (decl);
gcc_assert (!node->nested);
#ifdef ENABLE_CHECKING
verify_cgraph ();
#endif
+
+ /* Call functions declared with the "constructor" or "destructor"
+ attribute. */
+ cgraph_build_cdtor_fns ();
if (!flag_unit_at_a_time)
{
cgraph_assemble_pending_functions ();
#endif
return first_clone;
}
+
+#include "gt-cgraphunit.h"
+2007-05-11 Jan Hubicka <jh@suse.cz>
+
+ * semantics.c (expand_or_defer_fn): Do not call c_record_cdtor_fn.
+ * decl2.c (start_objects): ctors and dtors are no longer public.
+ (cp_write_global_declarations): Do not call c_build_cdtor_fns.
+
2007-05-07 Andrew Pinski <andrew_pinski@playstation.sony.com>
* typeck.c (build_unary_op): Remove code that used to
void_list_node));
start_preparsed_function (fndecl, /*attrs=*/NULL_TREE, SF_PRE_PARSED);
- /* It can be a static function as long as collect2 does not have
- to scan the object file to find its ctor/dtor routine. */
- TREE_PUBLIC (current_function_decl) = ! targetm.have_ctors_dtors;
+ TREE_PUBLIC (current_function_decl) = 0;
/* Mark this declaration as used to avoid spurious warnings. */
TREE_USED (current_function_decl) = 1;
if (priority_info_map)
splay_tree_delete (priority_info_map);
- c_build_cdtor_fns ();
-
/* Generate any missing aliases. */
maybe_apply_pending_pragma_weaks ();
return;
}
- /* Keep track of functions declared with the "constructor" and
- "destructor" attribute. */
- c_record_cdtor_fn (fn);
-
/* We make a decision about linkage for these functions at the end
of the compilation. Until that point, we do not want the back
end to output them -- but we do want it to see the bodies of