This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix constructors/destructors on some targets


Hi,
on AIX we add constructors/destructors to the cgraph just after
finishing last compilation unit and before starting cgraph optimizing.
While writing cgraph_add_new_function I didn' really considered this
case, so the function end up in the list of new functions, but we never
process them before IPA passes.
This patch fixes them by analyzing new functions added after the last
source level unit (as this behaviour is sane from the side of frotnends
- the functions are calling other constructors/destructors and really
don't belong to any of source level units)

Bootstrapped/regtested i686-linux, comitted.
Honza

	* cgraphunit.c (cgraph_process_new_functions): Reset reachable flag.
	(cgraph_analyze_function): break out from ...
	(cgraph_finalize_compilation_unit): ... here.
	(cgraph_expand_function): Remove forgoten commented out line.
	(cgraph_optimize): Analyze functions.
Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 120549)
--- cgraphunit.c	(working copy)
*************** cgraph_process_new_functions (void)
*** 280,285 ****
--- 280,286 ----
  	     it into reachable functions list.  */
  
  	  node->next_needed = NULL;
+ 	  node->needed = node->reachable = false;
  	  cgraph_finalize_function (fndecl, false);
  	  cgraph_mark_reachable_node (node);
  	  output = true;
*************** process_function_and_variable_attributes
*** 781,818 ****
      }
  }
  
! /* Analyze the whole compilation unit once it is parsed completely.  */
  
! void
! cgraph_finalize_compilation_unit (void)
  {
-   struct cgraph_node *node, *next;
    /* Keep track of already processed nodes when called multiple times for
       intermodule optimization.  */
    static struct cgraph_node *first_analyzed;
    struct cgraph_node *first_processed = first_analyzed;
    static struct varpool_node *first_analyzed_var;
  
-   if (errorcount || sorrycount)
-     return;
- 
-   finish_aliases_1 ();
- 
-   if (!flag_unit_at_a_time)
-     {
-       cgraph_output_pending_asms ();
-       cgraph_assemble_pending_functions ();
-       varpool_output_debug_info ();
-       return;
-     }
- 
-   if (!quiet_flag)
-     {
-       fprintf (stderr, "\nAnalyzing compilation unit\n");
-       fflush (stderr);
-     }
- 
-   timevar_push (TV_CGRAPH);
    process_function_and_variable_attributes (first_processed,
  					    first_analyzed_var);
    first_processed = cgraph_nodes;
--- 782,802 ----
      }
  }
  
! /* Process CGRAPH_NODES_NEEDED queue, analyze each function (and transitively
!    each reachable functions) and build cgraph.
!    The function can be called multiple times after inserting new nodes
!    into beggining of queue.  Just the new part of queue is re-scanned then.  */
  
! static void
! cgraph_analyze_functions (void)
  {
    /* Keep track of already processed nodes when called multiple times for
       intermodule optimization.  */
    static struct cgraph_node *first_analyzed;
    struct cgraph_node *first_processed = first_analyzed;
    static struct varpool_node *first_analyzed_var;
+   struct cgraph_node *node, *next;
  
    process_function_and_variable_attributes (first_processed,
  					    first_analyzed_var);
    first_processed = cgraph_nodes;
*************** cgraph_finalize_compilation_unit (void)
*** 826,831 ****
--- 810,816 ----
  	  fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
        fprintf (cgraph_dump_file, "\n");
      }
+   cgraph_process_new_functions ();
  
    /* Propagate reachability flag and lower representation of all reachable
       functions.  In the future, lowering will introduce new functions and
*************** cgraph_finalize_compilation_unit (void)
*** 865,870 ****
--- 850,856 ----
        first_processed = cgraph_nodes;
        first_analyzed_var = varpool_nodes;
        varpool_analyze_pending_decls ();
+       cgraph_process_new_functions ();
      }
  
    /* Collect entry points to the unit.  */
*************** cgraph_finalize_compilation_unit (void)
*** 908,913 ****
--- 894,927 ----
      }
    first_analyzed = cgraph_nodes;
    ggc_collect ();
+ }
+ 
+ /* Analyze the whole compilation unit once it is parsed completely.  */
+ 
+ void
+ cgraph_finalize_compilation_unit (void)
+ {
+   if (errorcount || sorrycount)
+     return;
+ 
+   finish_aliases_1 ();
+ 
+   if (!flag_unit_at_a_time)
+     {
+       cgraph_output_pending_asms ();
+       cgraph_assemble_pending_functions ();
+       varpool_output_debug_info ();
+       return;
+     }
+ 
+   if (!quiet_flag)
+     {
+       fprintf (stderr, "\nAnalyzing compilation unit\n");
+       fflush (stderr);
+     }
+ 
+   timevar_push (TV_CGRAPH);
+   cgraph_analyze_functions ();
    timevar_pop (TV_CGRAPH);
  }
  /* Figure out what functions we want to assemble.  */
*************** cgraph_expand_function (struct cgraph_no
*** 971,977 ****
      announce_function (decl);
  
    gcc_assert (node->lowered);
-   /*cgraph_lower_function (node);*/
  
    /* Generate RTL for the body of DECL.  */
    lang_hooks.callgraph.expand_function (decl);
--- 985,990 ----
*************** cgraph_optimize (void)
*** 1263,1269 ****
    /* Frontend may output common variables after the unit has been finalized.
       It is safe to deal with them here as they are always zero initialized.  */
    varpool_analyze_pending_decls ();
!   cgraph_process_new_functions ();
  
    timevar_push (TV_CGRAPHOPT);
    if (pre_ipa_mem_report)
--- 1276,1282 ----
    /* Frontend may output common variables after the unit has been finalized.
       It is safe to deal with them here as they are always zero initialized.  */
    varpool_analyze_pending_decls ();
!   cgraph_analyze_functions ();
  
    timevar_push (TV_CGRAPHOPT);
    if (pre_ipa_mem_report)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]