summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2007-05-11 14:18:17 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2007-05-11 12:18:17 +0000
commit7be82279042841a50c9a3464fce35c471fa07f1c (patch)
tree49ba9f2d2dd225ffee2443da3491e4fa57aa17a0
parent2a5fce6d487573f7f330d721da83fd9881fdb06a (diff)
downloadgcc-7be82279042841a50c9a3464fce35c471fa07f1c.tar.gz
semantics.c (expand_or_defer_fn): Do not call c_record_cdtor_fn.
* 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
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/Makefile.in5
-rw-r--r--gcc/c-common.c60
-rw-r--r--gcc/c-common.h7
-rw-r--r--gcc/c-decl.c8
-rw-r--r--gcc/cgraphunit.c76
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c6
-rw-r--r--gcc/cp/semantics.c4
9 files changed, 101 insertions, 86 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aee5d83ac9d..1b53da5a226 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+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
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ad90a7ca21c..5f1ce62ab52 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2370,7 +2370,8 @@ cgraphunit.o : cgraphunit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(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
@@ -2965,7 +2966,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.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, \
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 4e92ae6073d..f93cac5f696 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -670,11 +670,6 @@ const struct attribute_spec c_common_format_attribute_table[] =
{ 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
@@ -6994,61 +6989,6 @@ warn_for_unused_label (tree label)
}
}
-/* 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
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 5e97211cb17..7cbc6d5d9a0 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -1005,11 +1005,4 @@ extern tree c_omp_remap_decl (tree, bool);
#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 */
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 3af18571794..9feb25ce4c8 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -6799,10 +6799,6 @@ finish_function (void)
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);
@@ -7923,10 +7919,6 @@ c_write_global_declarations (void)
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 ();
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 13079a2b803..7a043d0edea 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -168,6 +168,75 @@ static void cgraph_output_pending_asms (void);
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
@@ -458,6 +527,7 @@ cgraph_finalize_function (tree decl, bool nested)
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);
@@ -1222,6 +1292,10 @@ cgraph_optimize (void)
#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 ();
@@ -1572,3 +1646,5 @@ save_inline_function_body (struct cgraph_node *node)
#endif
return first_clone;
}
+
+#include "gt-cgraphunit.h"
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 708da19eeef..b63882782be 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 5788f94ca13..9eb6fd5c1ce 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2333,9 +2333,7 @@ start_objects (int method_type, int initp)
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;
@@ -3299,8 +3297,6 @@ cp_write_global_declarations (void)
if (priority_info_map)
splay_tree_delete (priority_info_map);
- c_build_cdtor_fns ();
-
/* Generate any missing aliases. */
maybe_apply_pending_pragma_weaks ();
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a920bfb6ce7..a484c053353 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3188,10 +3188,6 @@ expand_or_defer_fn (tree fn)
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