diff options
author | Jan Hubicka <jh@suse.cz> | 2006-12-20 10:09:50 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2006-12-20 09:09:50 +0000 |
commit | 68e56cc4a27bff0dab7f2fc3bcf8353583771f98 (patch) | |
tree | 21dd0c062d62565d1fbbf16f1fd779965b554ca6 /gcc | |
parent | 7954dc21214b87ad8b3cf26994af00f968fcba78 (diff) | |
download | gcc-68e56cc4a27bff0dab7f2fc3bcf8353583771f98.zip gcc-68e56cc4a27bff0dab7f2fc3bcf8353583771f98.tar.gz gcc-68e56cc4a27bff0dab7f2fc3bcf8353583771f98.tar.bz2 |
cgraph.h (FOR_EACH_STATIC_VARIABLE, [...]): New macros.
* cgraph.h (FOR_EACH_STATIC_VARIABLE, FOR_EACH_STATIC_INITIALIZER): New
macros.
(varpool_first_static_initializer, varpol_next_static_initializer): New
inline functions.
* ipa-reference.c (analyze_variable): Simplify.
(static_execute): Use FOR_EACH_STATIC_INITIALIZER.
* ipa-type-escape.c (type_escape_execute): Use FOR_EACH_STATIC_VARIABLE.
From-SVN: r120070
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraph.h | 36 | ||||
-rw-r--r-- | gcc/ipa-reference.c | 11 | ||||
-rw-r--r-- | gcc/ipa-type-escape.c | 2 |
4 files changed, 50 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a5aadaf..0a36da5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2006-12-19 Jan Hubicka <jh@suse.cz> + + * cgraph.h (FOR_EACH_STATIC_VARIABLE, FOR_EACH_STATIC_INITIALIZER): New + macros. + (varpool_first_static_initializer, varpol_next_static_initializer): New + inline functions. + * ipa-reference.c (analyze_variable): Simplify. + (static_execute): Use FOR_EACH_STATIC_INITIALIZER. + * ipa-type-escape.c (type_escape_execute): Use FOR_EACH_STATIC_VARIABLE. + 2006-12-19 Andrew Pinski <pinskia@gmail.com> PR tree-opt/30045 diff --git a/gcc/cgraph.h b/gcc/cgraph.h index b60239c..8d4fe75 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -342,6 +342,42 @@ bool varpool_analyze_pending_decls (void); void varpool_output_debug_info (void); void varpool_remove_unreferenced_decls (void); +/* Walk all reachable static variables. */ +#define FOR_EACH_STATIC_VARIABLE(node) \ + for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed) + +/* Return first reachable static variable with initializer. */ +static inline struct varpool_node * +varpool_first_static_initializer (void) +{ + struct varpool_node *node; + for (node = varpool_nodes_queue; node; node = node->next_needed) + { + gcc_assert (TREE_CODE (node->decl) == VAR_DECL); + if (DECL_INITIAL (node->decl)) + return node; + } + return NULL; +} + +/* Return next reachable static variable with initializer after NODE. */ +static inline struct varpool_node * +varpool_next_static_initializer (struct varpool_node *node) +{ + for (node = node->next_needed; node; node = node->next_needed) + { + gcc_assert (TREE_CODE (node->decl) == VAR_DECL); + if (DECL_INITIAL (node->decl)) + return node; + } + return NULL; +} + +/* Walk all static variables with initializer set. */ +#define FOR_EACH_STATIC_INITIALIZER(node) \ + for ((node) = varpool_first_static_initializer (); (node); \ + (node) = varpool_next_static_initializer (node)) + /* In ipa-inline.c */ bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool); void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool); diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 521c84c..8602afd 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -774,13 +774,8 @@ static void analyze_variable (struct varpool_node *vnode) { tree global = vnode->decl; - if (TREE_CODE (global) == VAR_DECL) - { - if (DECL_INITIAL (global)) - walk_tree (&DECL_INITIAL (global), scan_for_static_refs, - NULL, visited_nodes); - } - else gcc_unreachable (); + walk_tree (&DECL_INITIAL (global), scan_for_static_refs, + NULL, visited_nodes); } /* This is the main routine for finding the reference patterns for @@ -903,7 +898,7 @@ static_execute (void) ipa_init (); /* Process all of the variables first. */ - for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) + FOR_EACH_STATIC_INITIALIZER (vnode) analyze_variable (vnode); /* Process all of the functions next. diff --git a/gcc/ipa-type-escape.c b/gcc/ipa-type-escape.c index faddb77..a7749f4 100644 --- a/gcc/ipa-type-escape.c +++ b/gcc/ipa-type-escape.c @@ -1682,7 +1682,7 @@ type_escape_execute (void) ipa_init (); /* Process all of the variables first. */ - for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) + FOR_EACH_STATIC_VARIABLE (vnode) analyze_variable (vnode); /* Process all of the functions. next |