This fixes PR54709, the location change broke DECL_IS_BUILTIN which
is bogously used by streamer_handle_as_builtin_p.  I am reverting
the previous lto-symtab.c change as it is not necessary for fixing
the testcases.  LTO bootstrap fails with this again with

/tmp/cca0yEEE.ltrans17.ltrans.o: In function `is_ctor_or_dtor.16889':
/space/rguenther/src/svn/trunk2/libiberty/cp-demangle.c:5506: undefined 
reference to `alloca'
/space/rguenther/src/svn/trunk2/libiberty/cp-demangle.c:5507: undefined 
reference to `alloca'
/tmp/cca0yEEE.ltrans17.ltrans.o: In function `d_demangle_callback.16926':
/space/rguenther/src/svn/trunk2/libiberty/cp-demangle.c:5227: undefined 
reference to `alloca'
/space/rguenther/src/svn/trunk2/libiberty/cp-demangle.c:5228: undefined 
reference to `alloca'
collect2: error: ld returned 1 exit status

but we want a testcase for this instead of having it magically "fixed"
without being analyzed.

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

Richard.

2012-09-26  Richard Guenther  <rguent...@suse.de>

        PR lto/54709
        * tree.h (DECL_IS_BUILTIN): Compare LOCATION_LOCUS.
        * tree-streamer.h (streamer_handle_as_builtin_p): Use DECL_BUILT_IN.
        * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Revert previous
        change.

        * gcc.dg/lto/pr54709_0.c: New testcase.
        * gcc.dg/lto/pr54709_1.c: Likewise.

Index: gcc/tree.h
===================================================================
*** gcc/tree.h  (revision 191756)
--- gcc/tree.h  (working copy)
*************** struct function;
*** 2617,2623 ****
  #define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE))
  #define DECL_SOURCE_COLUMN(NODE) LOCATION_COLUMN (DECL_SOURCE_LOCATION (NODE))
  #define DECL_IS_BUILTIN(DECL) \
!   (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION)
  
  /*  For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or
      QUAL_UNION_TYPE node that the field is a member of.  For VAR_DECL,
--- 2617,2623 ----
  #define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE))
  #define DECL_SOURCE_COLUMN(NODE) LOCATION_COLUMN (DECL_SOURCE_LOCATION (NODE))
  #define DECL_IS_BUILTIN(DECL) \
!   (LOCATION_LOCUS (DECL_SOURCE_LOCATION (DECL)) <= BUILTINS_LOCATION)
  
  /*  For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or
      QUAL_UNION_TYPE node that the field is a member of.  For VAR_DECL,
Index: gcc/tree-streamer.h
===================================================================
*** gcc/tree-streamer.h (revision 191756)
--- gcc/tree-streamer.h (working copy)
*************** struct streamer_tree_cache_d
*** 57,66 ****
  static inline bool
  streamer_handle_as_builtin_p (tree expr)
  {
!   return (TREE_CODE (expr) == FUNCTION_DECL
!         && DECL_IS_BUILTIN (expr)
!         && (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL
!             || DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD));
  }
  
  /* In tree-streamer-in.c.  */
--- 57,63 ----
  static inline bool
  streamer_handle_as_builtin_p (tree expr)
  {
!   return (TREE_CODE (expr) == FUNCTION_DECL && DECL_BUILT_IN (expr));
  }
  
  /* In tree-streamer-in.c.  */
Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c    (revision 191756)
--- gcc/lto-symtab.c    (working copy)
*************** lto_symtab_merge_cgraph_nodes_1 (symtab_
*** 629,636 ****
  
        if (!symtab_real_symbol_p (e))
        continue;
!       if (symtab_function_p (e)
!         && !DECL_BUILT_IN (e->symbol.decl))
        lto_cgraph_replace_node (cgraph (e), cgraph (prevailing));
        if (symtab_variable_p (e))
        lto_varpool_replace_node (varpool (e), varpool (prevailing));
--- 629,635 ----
  
        if (!symtab_real_symbol_p (e))
        continue;
!       if (symtab_function_p (e))
        lto_cgraph_replace_node (cgraph (e), cgraph (prevailing));
        if (symtab_variable_p (e))
        lto_varpool_replace_node (varpool (e), varpool (prevailing));
Index: gcc/testsuite/gcc.dg/lto/pr54709_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/pr54709_0.c        (revision 0)
--- gcc/testsuite/gcc.dg/lto/pr54709_0.c        (working copy)
***************
*** 0 ****
--- 1,9 ----
+ /* { dg-lto-do link } */
+ /* { dg-require-visibility "hidden" } */
+ /* { dg-extra-ld-options { -shared } } */
+ /* { dg-lto-options { { -w -fPIC -fvisibility=hidden -flto } } } */
+ 
+ foo ()
+ {
+   memcpy (0, 1, 1);
+ }
Index: gcc/testsuite/gcc.dg/lto/pr54709_1.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/pr54709_1.c        (revision 0)
--- gcc/testsuite/gcc.dg/lto/pr54709_1.c        (working copy)
***************
*** 0 ****
--- 1,5 ----
+ void * memcpy (void *, void *, long);
+ bar ()
+ {
+   memcpy (0, 1, 1);
+ }

Reply via email to