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] Fix PR45956


LTO bootstrap was broken by my DECL_CONTEXT change due to a odd
predicate in lto-streamer for mangling locals.  Fixed as follows.

Bootstrapped and tested on x86_64-unknown-linux-gnu, LTO bootstrapped,
applied to trunk.

Richard.

Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c	(revision 165233)
--- gcc/lto-streamer-in.c	(working copy)
*************** lto_input_tree_pointers (struct lto_inpu
*** 2367,2393 ****
  static void
  lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
  {
!   /* Register symbols with file or global scope to mark what input
!      file has their definition.  */
!   if (decl_function_context (decl) == NULL_TREE)
      {
!       /* Variable has file scope, not local. Need to ensure static variables
! 	 between different files don't clash unexpectedly.  */
!       if (!TREE_PUBLIC (decl))
!         {
! 	  /* ??? We normally pre-mangle names before we serialize them
! 	     out.  Here, in lto1, we do not know the language, and
! 	     thus cannot do the mangling again. Instead, we just
! 	     append a suffix to the mangled name.  The resulting name,
! 	     however, is not a properly-formed mangled name, and will
! 	     confuse any attempt to unmangle it.  */
! 	  const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
! 	  char *label;
  
! 	  ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
! 	  SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
!           rest_of_decl_compilation (decl, 1, 0);
!         }
      }
  
    /* If this variable has already been declared, queue the
--- 2367,2392 ----
  static void
  lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
  {
!   tree context;
! 
!   /* Variable has file scope, not local. Need to ensure static variables
!      between different files don't clash unexpectedly.  */
!   if (!TREE_PUBLIC (decl)
!       && !((context = decl_function_context (decl))
! 	   && auto_var_in_fn_p (decl, context)))
      {
!       /* ??? We normally pre-mangle names before we serialize them
! 	 out.  Here, in lto1, we do not know the language, and
! 	 thus cannot do the mangling again. Instead, we just
! 	 append a suffix to the mangled name.  The resulting name,
! 	 however, is not a properly-formed mangled name, and will
! 	 confuse any attempt to unmangle it.  */
!       const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
!       char *label;
  
!       ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
!       SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
!       rest_of_decl_compilation (decl, 1, 0);
      }
  
    /* If this variable has already been declared, queue the
Index: gcc/testsuite/gcc.dg/lto/20101009-2_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20101009-2_0.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20101009-2_0.c	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ /* { dg-lto-do link } */
+ 
+ int main() { return 0; }
Index: gcc/testsuite/gcc.dg/lto/20101009-2_1.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20101009-2_1.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20101009-2_1.c	(revision 0)
***************
*** 0 ****
--- 1,5 ----
+ int foo (void)
+ {
+   static int i;
+   return ++i;
+ }
Index: gcc/testsuite/gcc.dg/lto/20101009-2_2.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20101009-2_2.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20101009-2_2.c	(revision 0)
***************
*** 0 ****
--- 1,5 ----
+ int bar (void)
+ {
+   static int i;
+   return ++i;
+ }


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