diff gcc/ipa-utils.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/ipa-utils.h	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/ipa-utils.h	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Utilities for ipa analysis.
-   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   Copyright (C) 2004-2018 Free Software Foundation, Inc.
    Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
 
 This file is part of GCC.
@@ -55,6 +55,7 @@
 struct odr_type_d;
 typedef odr_type_d *odr_type;
 void build_type_inheritance_graph (void);
+void rebuild_type_inheritance_graph (void);
 void update_type_inheritance_graph (void);
 vec <cgraph_node *>
 possible_polymorphic_call_targets (tree, HOST_WIDE_INT,
@@ -178,22 +179,24 @@
 inline bool
 type_with_linkage_p (const_tree t)
 {
-  if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
-      || !TYPE_STUB_DECL (t))
+  if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL)
     return false;
-  /* In LTO do not get confused by non-C++ produced types or types built
-     with -fno-lto-odr-type-merigng.  */
+
+  /* To support -fno-lto-odr-type-merigng recognize types with vtables
+     to have linkage.  */
+  if (RECORD_OR_UNION_TYPE_P (t)
+      && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
+    return true;
+
+  /* After free_lang_data was run and -flto-odr-type-merging we can recongize
+     types with linkage by presence of mangled name.  */
+  if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+    return true;
+
   if (in_lto_p)
-    {
-      /* To support -fno-lto-odr-type-merigng recognize types with vtables
-         to have linkage.  */
-      if (RECORD_OR_UNION_TYPE_P (t)
-	  && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
-        return true;
-      /* With -flto-odr-type-merging C++ FE specify mangled names
-	 for all types with the linkage.  */
-      return DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
-    }
+    return false;
+  /* We used to check for TYPE_STUB_DECL but that is set to NULL for forward
+     declarations.  */
 
   if (!RECORD_OR_UNION_TYPE_P (t) && TREE_CODE (t) != ENUMERAL_TYPE)
     return false;
@@ -213,18 +216,16 @@
 {
   gcc_checking_assert (type_with_linkage_p (t));
 
-  if (!TREE_PUBLIC (TYPE_STUB_DECL (t)))
-    {
-      /* C++ FE uses magic <anon> as assembler names of anonymous types.
- 	 verify that this match with type_in_anonymous_namespace_p.  */
-      gcc_checking_assert (!in_lto_p
-			   || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))
-			   || !strcmp ("<anon>",
-				       IDENTIFIER_POINTER
-				       (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
-      return true;
-    }
-  return false;
+  /* free_lang_data clears TYPE_STUB_DECL but sets assembler name to
+     "<anon>"  */
+  if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+    return !strcmp ("<anon>",
+		    IDENTIFIER_POINTER
+		    (DECL_ASSEMBLER_NAME (TYPE_NAME (t))));
+  else if (!TYPE_STUB_DECL (t))
+    return false;
+  else
+    return !TREE_PUBLIC (TYPE_STUB_DECL (t));
 }
 
 /* Return true of T is type with One Definition Rule info attached.