From 7386e3ee260414735222ea6559f3bb94ecd011f9 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 16 Jul 2008 23:38:15 +0200 Subject: [PATCH] cgraph.h (varpool_empty_needed_queue): Declare. * cgraph.h (varpool_empty_needed_queue): Declare. * cgraphunit.c (output_in_order): Mark all variables as needed; empty the queue. * varpool.c (varpool_assemble_node): Update debug queue. (varpool_assemble_pending_decls): Don't do it here. (varpool_empty_needed_queue): New function. From-SVN: r137903 --- gcc/ChangeLog | 9 +++++++++ gcc/cgraph.h | 1 + gcc/cgraphunit.c | 10 ++++++++++ gcc/varpool.c | 35 ++++++++++++++++++++++++++++------- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2d1547e686..322e47d8399 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2008-07-16 Jan Hubicka + + * cgraph.h (varpool_empty_needed_queue): Declare. + * cgraphunit.c (output_in_order): Mark all variables as needed; + empty the queue. + * varpool.c (varpool_assemble_node): Update debug queue. + (varpool_assemble_pending_decls): Don't do it here. + (varpool_empty_needed_queue): New function. + 2008-07-16 Kaveh R. Ghazi * recog.c (peephole2_optimize): Fix formatting. diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 070bd77dcdc..b817f87f7f0 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -401,6 +401,7 @@ bool varpool_assemble_decl (struct varpool_node *node); bool varpool_analyze_pending_decls (void); void varpool_output_debug_info (void); void varpool_remove_unreferenced_decls (void); +void varpool_empty_needed_queue (void); /* Walk all reachable static variables. */ #define FOR_EACH_STATIC_VARIABLE(node) \ diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 2dcccc1bd93..5994ad12a03 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1291,6 +1291,16 @@ cgraph_output_in_order (void) nodes[i].u.a = pa; } + /* In toplevel reorder mode we output all statics; mark them as needed. */ + for (i = 0; i < max; ++i) + { + if (nodes[i].kind == ORDER_VAR) + { + varpool_mark_needed_node (nodes[i].u.v); + } + } + varpool_empty_needed_queue (); + for (i = 0; i < max; ++i) { switch (nodes[i].kind) diff --git a/gcc/varpool.c b/gcc/varpool.c index 4149c1d1d21..c2410f664f5 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -357,7 +357,13 @@ varpool_assemble_decl (struct varpool_node *node) && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl))) { assemble_variable (decl, 0, 1, 0); - return TREE_ASM_WRITTEN (decl); + if (TREE_ASM_WRITTEN (decl)) + { + node->next_needed = varpool_assembled_nodes_queue; + varpool_assembled_nodes_queue = node; + node->finalized = 1; + return true; + } } return false; @@ -423,12 +429,7 @@ varpool_assemble_pending_decls (void) varpool_nodes_queue = varpool_nodes_queue->next_needed; if (varpool_assemble_decl (node)) - { - changed = true; - node->next_needed = varpool_assembled_nodes_queue; - varpool_assembled_nodes_queue = node; - node->finalized = 1; - } + changed = true; else node->next_needed = NULL; } @@ -438,6 +439,26 @@ varpool_assemble_pending_decls (void) return changed; } +/* Remove all elements from the queue so we can re-use it for debug output. */ +void +varpool_empty_needed_queue (void) +{ + /* EH might mark decls as needed during expansion. This should be safe since + we don't create references to new function, but it should not be used + elsewhere. */ + varpool_analyze_pending_decls (); + + while (varpool_nodes_queue) + { + struct varpool_node *node = varpool_nodes_queue; + varpool_nodes_queue = varpool_nodes_queue->next_needed; + node->next_needed = NULL; + } + /* varpool_nodes_queue is now empty, clear the pointer to the last element + in the queue. */ + varpool_last_needed_node = NULL; +} + /* Output all variables enqueued to be assembled. */ void varpool_output_debug_info (void) -- 2.30.2