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]

[PATCH][LTO][C++] Fix PR42762, fix GTY issue


This fixes PR42762 by clearing DECL_LANG_SPECIFIC if eh-cleanup
makes it unnecessary.  It makes it work at -O0 by removing the
asserts from get_resolution and instead deal with the situaton
there.  The basic issue is that what we see at LTO bytecode
read is sth different than what the linker sees at symbol
resolution time (the former is just before IPA optimizations,
the latter is fully optimized).

This exposed that the C++ FE doesn't properly register the
root for cp_eh_personality_decl.  Fixed with the C++ bits.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Ok?

Thanks,
Richard.

2010-02-05  Richard Guenther  <rguenther@suse.de>

	PR lto/42762
	* tree-eh.c (execute_cleanup_eh_1): Copy from execute_cleanup_eh.
	(execute_cleanup_eh): Clear DECL_FUNCTION_PERSONALITY if it is
	no longer needed.
	* lto-streamer-in.c (get_resolution): Deal with references
	to undefined functions.

	cp/
	* Make-lang.in (cp/cp-lang.o): Depend on gt-cp-cp-lang.h.
	* cp-lang.c: Include gt-cp-cp-lang.h.
	* config-lang.in (gtfiles): Add cp/cp-lang.c.

Index: gcc/tree-eh.c
===================================================================
*** gcc/tree-eh.c	(revision 156493)
--- gcc/tree-eh.c	(working copy)
*************** cleanup_all_empty_eh (void)
*** 3796,3802 ****
  */
  
  static unsigned int
! execute_cleanup_eh (void)
  {
    /* Do this first: unsplit_all_eh and cleanup_all_empty_eh can die
       looking up unreachable landing pads.  */
--- 3796,3802 ----
  */
  
  static unsigned int
! execute_cleanup_eh_1 (void)
  {
    /* Do this first: unsplit_all_eh and cleanup_all_empty_eh can die
       looking up unreachable landing pads.  */
*************** execute_cleanup_eh (void)
*** 3830,3835 ****
--- 3830,3850 ----
    return 0;
  }
  
+ static unsigned int
+ execute_cleanup_eh (void)
+ {
+   int ret = execute_cleanup_eh_1 ();
+ 
+   /* If the function no longer needs an EH personality routine
+      clear it.  This exposes cross-language inlining opportunities
+      and avoids references to a never defined personality routine.  */
+   if (DECL_FUNCTION_PERSONALITY (current_function_decl)
+       && function_needs_eh_personality (cfun) != eh_personality_lang)
+     DECL_FUNCTION_PERSONALITY (current_function_decl) = NULL_TREE;
+ 
+   return ret;
+ }
+ 
  static bool
  gate_cleanup_eh (void)
  {
Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c	(revision 156493)
--- gcc/lto-streamer-in.c	(working copy)
*************** get_resolution (struct data_in *data_in,
*** 1515,1526 ****
    if (data_in->globals_resolution)
      {
        ld_plugin_symbol_resolution_t ret;
!       gcc_assert (index < VEC_length (ld_plugin_symbol_resolution_t,
! 				      data_in->globals_resolution));
        ret = VEC_index (ld_plugin_symbol_resolution_t,
  		       data_in->globals_resolution,
  		       index);
-       gcc_assert (ret != LDPR_UNKNOWN);
        return ret;
      }
    else
--- 1515,1529 ----
    if (data_in->globals_resolution)
      {
        ld_plugin_symbol_resolution_t ret;
!       /* We can have references to not emitted functions in
! 	 DECL_FUNCTION_PERSONALITY at least.  So we can and have
! 	 to indeed return LDPR_UNKNOWN in some cases.   */
!       if (VEC_length (ld_plugin_symbol_resolution_t,
! 		      data_in->globals_resolution) <= index)
! 	return LDPR_UNKNOWN;
        ret = VEC_index (ld_plugin_symbol_resolution_t,
  		       data_in->globals_resolution,
  		       index);
        return ret;
      }
    else
Index: gcc/cp/Make-lang.in
===================================================================
*** gcc/cp/Make-lang.in	(revision 156493)
--- gcc/cp/Make-lang.in	(working copy)
*************** CXX_PRETTY_PRINT_H = cp/cxx-pretty-print
*** 250,256 ****
  cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \
    $(C_PRAGMA_H) toplev.h output.h input.h cp/operators.def $(TM_P_H)
  cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h debug.h langhooks.h \
!   $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-cp.h \
    $(DIAGNOSTIC_H) cp/cp-objcp-common.h $(EXPR_H) $(EXCEPT_H)
  cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h \
    output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
--- 250,256 ----
  cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \
    $(C_PRAGMA_H) toplev.h output.h input.h cp/operators.def $(TM_P_H)
  cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h debug.h langhooks.h \
!   $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-cp.h gt-cp-cp-lang.h \
    $(DIAGNOSTIC_H) cp/cp-objcp-common.h $(EXPR_H) $(EXCEPT_H)
  cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h \
    output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
Index: gcc/cp/cp-lang.c
===================================================================
*** gcc/cp/cp-lang.c	(revision 156493)
--- gcc/cp/cp-lang.c	(working copy)
*************** cp_eh_personality (void)
*** 184,187 ****
--- 184,188 ----
    return cp_eh_personality_decl;
  }
  
+ #include "gt-cp-cp-lang.h"
  #include "gtype-cp.h"
Index: gcc/cp/config-lang.in
===================================================================
*** gcc/cp/config-lang.in	(revision 156493)
--- gcc/cp/config-lang.in	(working copy)
*************** compilers="cc1plus\$(exeext)"
*** 30,33 ****
  
  target_libs="target-libstdc++-v3"
  
! gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c"
--- 30,33 ----
  
  target_libs="target-libstdc++-v3"
  
! gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/cp-lang.c"


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