]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cgraph.h (symtab_first_defined_symbol, [...]): New functions.
authorJan Hubicka <hubicka@ucw.cz>
Sun, 18 May 2014 19:11:58 +0000 (21:11 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 18 May 2014 19:11:58 +0000 (19:11 +0000)
* cgraph.h (symtab_first_defined_symbol, symtab_next_defined_symbol):
New functions.
(FOR_EACH_DEFINED_SYMBOL): New macro.
(varpool_first_static_initializer, varpool_next_static_initializer,
varpool_first_defined_variable, varpool_next_defined_variable): Fix comments.
(symtab_in_same_comdat_p): Correctly deal with inline functions.

From-SVN: r210586

gcc/ChangeLog
gcc/cgraph.h

index 2775f333310b3382b720347ba37642896f819bb1..18ab7bd0d67ae43cc20b14477797f974eccf5bf5 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-17  Jan Hubicka  <hubicka@ucw.cz>
+
+       * cgraph.h (symtab_first_defined_symbol, symtab_next_defined_symbol):
+       New functions.
+       (FOR_EACH_DEFINED_SYMBOL): New macro.
+       (varpool_first_static_initializer, varpool_next_static_initializer,
+       varpool_first_defined_variable, varpool_next_defined_variable): Fix comments.
+       (symtab_in_same_comdat_p): Correctly deal with inline functions.
+
 2014-05-17  Trevor Saunders  <tsaunders@mozilla.com>
 
        * ggc-page.c (ggc_handle_finalizers): Add comment.
index a29a31c4b67ac0860aee7eb2acb382b2a9eb73d5..8f13ecbe11cefcc4e18891ef1a928181659a7625 100644 (file)
@@ -1024,6 +1024,35 @@ varpool_get_node (const_tree decl)
 #define FOR_EACH_SYMBOL(node) \
    for ((node) = symtab_nodes; (node); (node) = (node)->next)
 
+/* Return first static symbol with definition.  */
+static inline symtab_node *
+symtab_first_defined_symbol (void)
+{
+  symtab_node *node;
+
+  for (node = symtab_nodes; node; node = node->next)
+    if (node->definition)
+      return node;
+
+  return NULL;
+}
+
+/* Return next reachable static symbol with initializer after NODE.  */
+static inline symtab_node *
+symtab_next_defined_symbol (symtab_node *node)
+{
+  symtab_node *node1 = node->next;
+
+  for (; node1; node1 = node1->next)
+    if (node1->definition)
+      return node1;
+
+  return NULL;
+}
+/* Walk all symbols with definitions in current unit.  */
+#define FOR_EACH_DEFINED_SYMBOL(node) \
+   for ((node) = symtab_first_defined_symbol (); (node); \
+        (node) = symtab_next_defined_symbol (node))
 
 /* Return first variable.  */
 static inline varpool_node *
@@ -1052,7 +1081,7 @@ varpool_next_variable (varpool_node *node)
         (node); \
        (node) = varpool_next_variable ((node)))
 
-/* Return first reachable static variable with initializer.  */
+/* Return first static variable with initializer.  */
 static inline varpool_node *
 varpool_first_static_initializer (void)
 {
@@ -1066,7 +1095,7 @@ varpool_first_static_initializer (void)
   return NULL;
 }
 
-/* Return next reachable static variable with initializer after NODE.  */
+/* Return next static variable with initializer after NODE.  */
 static inline varpool_node *
 varpool_next_static_initializer (varpool_node *node)
 {
@@ -1085,7 +1114,7 @@ varpool_next_static_initializer (varpool_node *node)
    for ((node) = varpool_first_static_initializer (); (node); \
         (node) = varpool_next_static_initializer (node))
 
-/* Return first reachable static variable with initializer.  */
+/* Return first static variable with definition.  */
 static inline varpool_node *
 varpool_first_defined_variable (void)
 {
@@ -1099,7 +1128,7 @@ varpool_first_defined_variable (void)
   return NULL;
 }
 
-/* Return next reachable static variable with initializer after NODE.  */
+/* Return next static variable with definition after NODE.  */
 static inline varpool_node *
 varpool_next_defined_variable (varpool_node *node)
 {
@@ -1539,6 +1568,17 @@ symtab_comdat_local_p (symtab_node *node)
 static inline bool
 symtab_in_same_comdat_p (symtab_node *one, symtab_node *two)
 {
+  if (cgraph_node *cn = dyn_cast <cgraph_node *> (one))
+    {
+      if (cn->global.inlined_to)
+       one = cn->global.inlined_to;
+    }
+  if (cgraph_node *cn = dyn_cast <cgraph_node *> (two))
+    {
+      if (cn->global.inlined_to)
+       two = cn->global.inlined_to;
+    }
+
   return DECL_COMDAT_GROUP (one->decl) == DECL_COMDAT_GROUP (two->decl);
 }
 #endif  /* GCC_CGRAPH_H  */