]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
semantics.c (expand_or_defer_fn): Do not call c_record_cdtor_fn.
authorJan Hubicka <jh@suse.cz>
Fri, 11 May 2007 12:18:17 +0000 (14:18 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 11 May 2007 12:18:17 +0000 (12:18 +0000)
* 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

gcc/ChangeLog
gcc/Makefile.in
gcc/c-common.c
gcc/c-common.h
gcc/c-decl.c
gcc/cgraphunit.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/semantics.c

index aee5d83ac9dfd3fb3331acb13cc107ddab2eec28..1b53da5a2262b02403694c5ba047ba2816f030eb 100644 (file)
@@ -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
index ad90a7ca21c9b49db45827236c3b5e3ccaa43079..5f1ce62ab52935fd2849db13edf72e5db6e261e2 100644 (file)
@@ -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, \
index 4e92ae6073dfc3ad0ba6bb2cdf3b1cc9a87a07b3..f93cac5f69658fe6a9e0528143f8ab47d2ffba91 100644 (file)
@@ -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
index 5e97211cb178092aa43f663d93e99373400ec957..7cbc6d5d9a08af956899127de16bdd41d3ed156f 100644 (file)
@@ -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 */
index 3af1857179432afc06ea53bea9b4d073c32410e6..9feb25ce4c8ac8c5efb29c2e5bab189294ed835e 100644 (file)
@@ -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 ();
index 13079a2b80314a4d11a1c35474083296544c8a2b..7a043d0edea0a5fa1eaee7d9c3144c28ed9699f3 100644 (file)
@@ -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"
index 708da19eeef37ecabaad9658d81bbc4f82819421..b63882782be14f5bf0a638f26b81fcd306e69622 100644 (file)
@@ -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
index 5788f94ca13fe77167272037debe7d87382fa53e..9eb6fd5c1ce70a1619396660bb8f9fdd028df944 100644 (file)
@@ -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 ();
 
index a920bfb6ce7fae8743ddc044e87f4928a1259dd5..a484c0533533b17070ed8ed7c36ff5ef20ef7e28 100644 (file)
@@ -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