From 52638b9cb5897ef7b4a23ad6b5884ae2a7a852a8 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 18 May 2014 19:11:58 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210586 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/cgraph.h | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2775f333310..18ab7bd0d67 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2014-05-17 Jan Hubicka + + * 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 * ggc-page.c (ggc_handle_finalizers): Add comment. diff --git a/gcc/cgraph.h b/gcc/cgraph.h index a29a31c4b67..8f13ecbe11c 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -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 (one)) + { + if (cn->global.inlined_to) + one = cn->global.inlined_to; + } + if (cgraph_node *cn = dyn_cast (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 */ -- 2.11.4.GIT