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]

PR debug/26881 (dwarf2out ICE)


Hi,
this patch fix PR debug/26881 by making cgraph code to output debug info on
local statics later, after the functions themselves was output.  I've
bootstrapped/regtested the patch on i686-linux, if no one complains, I will
commit it tomorrow together with the testcase.

I've also fixed few typos on the way.
Honza
2006-08-23  Jan Hubicka  <jh@suse.cz>
	PR debug/26881
	* cgraph.c: Fix comments.
	(cgraph_varpool_mark_needed_node): Mark only variables not already
	output to file.
	* cgraphunit.c: Update comments; include gt-cgraphunit.h
	(cgraph_varpool_assembled_nodes_queue): New static variable.
	(cgraph_varpool_assemble_decl): Record output decls for debug out code.
	(cgraph_varpool_output_debug_info): New function.
	(cgraph_finalize_compilation_unit, cgraph_optimize): Call it.
	* Makefile.in: Add gt-cgraphunit.h
Index: cgraph.c
===================================================================
*** cgraph.c	(revision 116257)
--- cgraph.c	(working copy)
*************** The callgraph:
*** 47,55 ****
      be accessed in such an invisible way and it shall be considered an
      entry point to the callgraph.
  
!     Intraprocedural information:
  
!       Callgraph is place to store data needed for intraprocedural optimization.
        All data structures are divided into three components: local_info that
        is produced while analyzing the function, global_info that is result
        of global walking of the callgraph on the end of compilation and
--- 47,55 ----
      be accessed in such an invisible way and it shall be considered an
      entry point to the callgraph.
  
!     Interprocedural information:
  
!       Callgraph is place to store data needed for interprocedural optimization.
        All data structures are divided into three components: local_info that
        is produced while analyzing the function, global_info that is result
        of global walking of the callgraph on the end of compilation and
*************** cgraph_varpool_reset_queue (void)
*** 835,841 ****
  void
  cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *node)
  {
!   if (!node->needed && node->finalized)
      cgraph_varpool_enqueue_needed_node (node);
    node->needed = 1;
  }
--- 835,842 ----
  void
  cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *node)
  {
!   if (!node->needed && node->finalized
!       && !TREE_ASM_WRITTEN (node->decl))
      cgraph_varpool_enqueue_needed_node (node);
    node->needed = 1;
  }
Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 116257)
--- cgraphunit.c	(working copy)
***************
*** 1,4 ****
! /* Callgraph based intraprocedural optimizations.
     Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
     Contributed by Jan Hubicka
  
--- 1,4 ----
! /* Callgraph based interprocedural optimizations.
     Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
     Contributed by Jan Hubicka
  
*************** Software Foundation, 51 Franklin Street,
*** 20,26 ****
  02110-1301, USA.  */
  
  /* This module implements main driver of compilation process as well as
!    few basic intraprocedural optimizers.
  
     The main scope of this file is to act as an interface in between
     tree based frontends and the backend (and middle end)
--- 20,26 ----
  02110-1301, USA.  */
  
  /* This module implements main driver of compilation process as well as
!    few basic interprocedural optimizers.
  
     The main scope of this file is to act as an interface in between
     tree based frontends and the backend (and middle end)
*************** static tree record_reference (tree *, in
*** 174,179 ****
--- 174,182 ----
  static void cgraph_output_pending_asms (void);
  static void cgraph_increase_alignment (void);
  
+ /* Lists all assembled variables to be sent to debugger output later on.  */
+ static GTY(()) struct cgraph_varpool_node *cgraph_varpool_assembled_nodes_queue;
+ 
  /* Records tree nodes seen in record_reference.  Simply using
     walk_tree_without_duplicates doesn't guarantee each node is visited
     once because it gets a new htab upon each recursive call from
*************** cgraph_varpool_assemble_decl (struct cgr
*** 856,873 ****
        && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)))
      {
        assemble_variable (decl, 0, 1, 0);
!       /* Local static variables are never seen by check_global_declarations
! 	 so we need to output debug info by hand.  */
!       if (DECL_CONTEXT (decl)
! 	  && (TREE_CODE (DECL_CONTEXT (decl)) == BLOCK
! 	      || TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
! 	  && errorcount == 0 && sorrycount == 0)
! 	{
! 	  timevar_push (TV_SYMOUT);
! 	  (*debug_hooks->global_decl) (decl);
! 	  timevar_pop (TV_SYMOUT);
! 	}
!       return true;
      }
  
    return false;
--- 859,865 ----
        && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)))
      {
        assemble_variable (decl, 0, 1, 0);
!       return TREE_ASM_WRITTEN (decl);
      }
  
    return false;
*************** cgraph_varpool_assemble_pending_decls (v
*** 893,903 ****
  
        cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
        if (cgraph_varpool_assemble_decl (node))
! 	changed = true;
!       node->next_needed = NULL;
      }
    return changed;
  }
  
  /* Output all asm statements we have stored up to be output.  */
  
--- 885,923 ----
  
        cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
        if (cgraph_varpool_assemble_decl (node))
! 	{
! 	  changed = true;
! 	  node->next_needed = cgraph_varpool_assembled_nodes_queue;
! 	  cgraph_varpool_assembled_nodes_queue = node;
! 	  node->finalized = 1;
! 	}
!       else
!         node->next_needed = NULL;
      }
    return changed;
  }
+ /* Output all variables enqueued to be assembled.  */
+ static void
+ cgraph_varpool_output_debug_info (void)
+ {
+   timevar_push (TV_SYMOUT);
+   if (errorcount == 0 && sorrycount == 0)
+     while (cgraph_varpool_assembled_nodes_queue)
+       {
+ 	struct cgraph_varpool_node *node = cgraph_varpool_assembled_nodes_queue;
+ 
+ 	/* Local static variables are never seen by check_global_declarations
+ 	   so we need to output debug info by hand.  */
+ 	if (DECL_CONTEXT (node->decl)
+ 	    && (TREE_CODE (DECL_CONTEXT (node->decl)) == BLOCK
+ 		|| TREE_CODE (DECL_CONTEXT (node->decl)) == FUNCTION_DECL)
+ 	    && errorcount == 0 && sorrycount == 0)
+ 	     (*debug_hooks->global_decl) (node->decl);
+ 	cgraph_varpool_assembled_nodes_queue = node->next_needed;
+ 	node->next_needed = 0;
+       }
+   timevar_pop (TV_SYMOUT);
+ }
  
  /* Output all asm statements we have stored up to be output.  */
  
*************** cgraph_finalize_compilation_unit (void)
*** 1042,1047 ****
--- 1062,1068 ----
      {
        cgraph_output_pending_asms ();
        cgraph_assemble_pending_functions ();
+       cgraph_varpool_output_debug_info ();
        return;
      }
  
*************** cgraph_optimize (void)
*** 1494,1499 ****
--- 1515,1521 ----
      {
        cgraph_output_pending_asms ();
        cgraph_varpool_assemble_pending_decls ();
+       cgraph_varpool_output_debug_info ();
        return;
      }
  
*************** cgraph_optimize (void)
*** 1505,1511 ****
  
    timevar_push (TV_CGRAPHOPT);
    if (!quiet_flag)
!     fprintf (stderr, "Performing intraprocedural optimizations\n");
  
    cgraph_function_and_variable_visibility ();
    if (cgraph_dump_file)
--- 1527,1533 ----
  
    timevar_push (TV_CGRAPHOPT);
    if (!quiet_flag)
!     fprintf (stderr, "Performing interprocedural optimizations\n");
  
    cgraph_function_and_variable_visibility ();
    if (cgraph_dump_file)
*************** cgraph_optimize (void)
*** 1550,1555 ****
--- 1572,1578 ----
        cgraph_varpool_remove_unreferenced_decls ();
  
        cgraph_varpool_assemble_pending_decls ();
+       cgraph_varpool_output_debug_info ();
      }
  
    if (cgraph_dump_file)
*************** save_inline_function_body (struct cgraph
*** 1890,1892 ****
--- 1913,1916 ----
    return first_clone;
  }
  
+ #include "gt-cgraphunit.h"
Index: Makefile.in
===================================================================
*** Makefile.in	(revision 116257)
--- Makefile.in	(working copy)
*************** cgraphunit.o : cgraphunit.c $(CONFIG_H) 
*** 2290,2296 ****
     $(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
  ipa.o : ipa.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(CGRAPH_H) 
  ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
     langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) ipa-prop.h \
--- 2290,2297 ----
     $(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 \
!    gt-cgraphunit.h
  ipa.o : ipa.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(CGRAPH_H) 
  ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
     langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) ipa-prop.h \
*************** GTFILES = $(srcdir)/input.h $(srcdir)/co
*** 2867,2873 ****
    $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
    $(srcdir)/tree-ssa-structalias.c \
    $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
!   $(srcdir)/targhooks.c $(out_file) \
    @all_gtfiles@
  
  GTFILES_FILES_LANGS = @all_gtfiles_files_langs@
--- 2868,2874 ----
    $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
    $(srcdir)/tree-ssa-structalias.c \
    $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
!   $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \
    @all_gtfiles@
  
  GTFILES_FILES_LANGS = @all_gtfiles_files_langs@
*************** gt-tree-profile.h gt-tree-ssa-address.h 
*** 2899,2905 ****
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-nested.h \
  gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
! gt-tree-ssa-structalias.h gt-ipa-inline.h \
  gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
  
  define echo_quoted_to_gtyp
--- 2900,2906 ----
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-nested.h \
  gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
! gt-tree-ssa-structalias.h gt-ipa-inline.h gt-cgraphunit.h \
  gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
  
  define echo_quoted_to_gtyp


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