Hi,
this patch fixes a thinko I introduced into lto_symtab_merge_decls_2
yesterday: a decl can not be prevailed by itself. 

Bootstrapped/regtested x86_64-linux, comitted.
        PR lto/68811
        * g++.dg/lto/pr68811_0.C: New testcase.
        * g++.dg/lto/pr68811_1.C: New testcase.

        * lto-symtab.c (lto_symtab_merge_decls_2): Decl can never be prevailed
        by itself.
Index: testsuite/g++.dg/lto/pr68811_0.C
===================================================================
--- testsuite/g++.dg/lto/pr68811_0.C    (revision 0)
+++ testsuite/g++.dg/lto/pr68811_0.C    (revision 0)
@@ -0,0 +1,11 @@
+// { dg-lto-do link }
+/* { dg-lto-options "-O2  -w" } */
+// { dg-extra-ld-options "-r -nostdlib" }
+extern "C" char *strcpy(char *, const char *);
+char InitXPCOMGlue_lastSlash;
+void InitXPCOMGlue() { strcpy(&InitXPCOMGlue_lastSlash, ".so"); }
+extern "C" void memcpy(void *);
+char LZ4_decompress_safe_usingDict_ip;
+void LZ4_decompress_safe_usingDict() {
+  memcpy(&LZ4_decompress_safe_usingDict_ip);
+}
Index: testsuite/g++.dg/lto/pr68811_1.C
===================================================================
--- testsuite/g++.dg/lto/pr68811_1.C    (revision 0)
+++ testsuite/g++.dg/lto/pr68811_1.C    (revision 0)
@@ -0,0 +1,94 @@
+// { dg-options "-O2 -flto -w" }
+template <typename> class allocator;
+template <typename _CharT, typename = _CharT, typename = allocator<_CharT>>
+class Trans_NS___cxx11_basic_string;
+struct __false_type {};
+template <typename> using __void_t = void;
+template <typename, typename, template <typename...> class, typename...>
+struct __detector {
+  using type = int;
+};
+template <typename _Default, template <typename...> class _Op,
+          typename... _Args>
+struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> {
+  using type = _Op<_Args...>;
+};
+template <typename _Default, template <typename...> class _Op,
+          typename... _Args>
+using __detected_or = __detector<_Default, void, _Op, _Args...>;
+template <typename _Default, template <typename...> class _Op,
+          typename... _Args>
+using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type;
+template <template <typename...> class _Default,
+          template <typename...> class _Op, typename... _Args>
+using __detected_or_t_ = __detected_or_t<_Default<_Args...>, _Op, _Args...>;
+struct random_access_iterator_tag {};
+class __undefined;
+template <typename, typename> using __replace_first_arg_t = __undefined;
+template <typename> class allocator {
+public:
+  template <typename> struct rebind { typedef allocator other; };
+};
+struct __allocator_traits_base {
+  template <typename _Alloc, typename _Up>
+  using __rebind = typename _Alloc::template rebind<_Up>::other;
+  template <typename _Tp> using __pointer = typename _Tp::pointer;
+  template <typename _Tp> using __size_type = typename _Tp::size_type;
+};
+template <typename _Alloc, typename _Up>
+using __alloc_rebind =
+    __detected_or_t_<__replace_first_arg_t, __allocator_traits_base::__rebind,
+                     _Alloc, _Up>;
+struct allocator_traits : __allocator_traits_base {
+  using pointer = __detected_or_t<char, __pointer, allocator<char>>;
+  using size_type = __detected_or_t<int, __size_type, allocator<char>>;
+  template <typename _Tp>
+  using rebind_alloc = __alloc_rebind<allocator<char>, _Tp>;
+};
+struct __alloc_traits : allocator_traits {
+  struct rebind {
+    typedef rebind_alloc<int> other;
+  };
+};
+template <typename, typename, typename> class Trans_NS___cxx11_basic_string {
+public:
+  struct _Alloc_hider : __alloc_traits::rebind::other {
+    _Alloc_hider(__alloc_traits::pointer, allocator);
+  } _M_dataplus;
+  __alloc_traits::pointer _M_local_data();
+  template <typename _InIterator>
+  void _M_construct_aux(_InIterator __beg, _InIterator __end, __false_type) {
+    _M_construct(__beg, __end, random_access_iterator_tag());
+  }
+  template <typename _InIterator>
+  void _M_construct(_InIterator __beg, _InIterator __end) {
+    _M_construct_aux(__beg, __end, __false_type());
+  }
+  template <typename _FwdIterator>
+  void _M_construct(_FwdIterator, _FwdIterator, random_access_iterator_tag);
+  char _S_copy___s2;
+  void _S_copy(char *, __alloc_traits::size_type __n) {
+    __builtin_memcpy(0, &_S_copy___s2, __n);
+  }
+  template <class _Iterator>
+  void _S_copy_chars(char *__p, _Iterator __k1, _Iterator __k2) {
+    _S_copy(__p, __k2 - __k1);
+  }
+  Trans_NS___cxx11_basic_string(char *__s,
+                                allocator<char> __a = allocator<char>())
+      : _M_dataplus(_M_local_data(), __a) {
+    _M_construct(__s, __s);
+  }
+};
+template <typename _CharT, typename _Traits, typename _Alloc>
+template <typename _InIterator>
+void Trans_NS___cxx11_basic_string<_CharT, _Traits, _Alloc>::_M_construct(
+    _InIterator __beg, _InIterator __end, random_access_iterator_tag) {
+  _S_copy_chars(0, __beg, __end);
+}
+class Decimal {
+  Trans_NS___cxx11_basic_string<char> toString() const;
+};
+Trans_NS___cxx11_basic_string<char> Decimal::toString() const {
+  return "Infinity";
+}
Index: alias.c
===================================================================
--- alias.c     (revision 231439)
+++ alias.c     (working copy)
@@ -990,6 +990,14 @@ get_alias_set (tree t)
           || TREE_CODE (p) == VECTOR_TYPE;
           p = TREE_TYPE (p))
        {
+         /* Ada supports recusive pointers.  Instead of doing recrusion check
+            just give up once the preallocated space of 8 elements is up.
+            In this case just punt to void * alias set.  */
+         if (reference.length () == 8)
+           {
+             p = ptr_type_node;
+             break;
+           }
          if (TREE_CODE (p) == REFERENCE_TYPE)
            /* In LTO we want languages that use references to be compatible
               with languages that use pointers.  */
Index: lto/lto-symtab.c
===================================================================
--- lto/lto-symtab.c    (revision 231439)
+++ lto/lto-symtab.c    (working copy)
@@ -568,7 +568,8 @@ lto_symtab_merge_decls_2 (symtab_node *f
       for (this_prevailing = prevailing; ;
           this_prevailing = this_prevailing->next_sharing_asm_name)
        {
-         if (lto_symtab_merge_p (this_prevailing->decl, e->decl))
+         if (this_prevailing->decl != e->decl
+             && lto_symtab_merge_p (this_prevailing->decl, e->decl))
            break;
          if (this_prevailing == last_prevailing)
            {
@@ -709,7 +710,7 @@ lto_symtab_merge_decls_1 (symtab_node *f
                && lto_symtab_symbol_p (e))
              prevailing = e;
        }
-      /* For variables prefer the non-builtin if one is available.  */
+      /* For functions prefer the non-builtin if one is available.  */
       else if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
        {
          for (e = first; e; e = e->next_sharing_asm_name)
Index: ipa-visibility.c
===================================================================
--- ipa-visibility.c    (revision 231439)
+++ ipa-visibility.c    (working copy)
@@ -720,7 +720,7 @@ function_and_variable_visibility (bool w
          bool found = false;
 
          /* See if there is something to update.  */
-         for (i = 0; vnode->iterate_referring (i, ref); i++)
+         for (i = 0; vnode->iterate_reference (i, ref); i++)
            if (ref->use == IPA_REF_ADDR
                && can_replace_by_local_alias_in_vtable (ref->referred))
              {

Reply via email to