/* Optimization of function bodies might've rendered some variables as unnecessary so we want to avoid these from being compiled. This is done by pruning the queue and keeping only the variables that really appear needed (ie they are either externally visible or referenced by compiled function). Re-doing the reachability analysis on variables brings back the remaining variables referenced by these. */ void varpool_remove_unreferenced_decls (void) { struct varpool_node *next, *node = varpool_nodes_queue; varpool_reset_queue (); if (seen_error ()) return; while (node) { next = node->next_needed; node->needed = 0; if (node->analyzed && (!varpool_can_remove_if_no_refs (node) /* We just expanded all function bodies. See if any of them needed the variable. */ || DECL_RTL_SET_P (node->decl))) varpool_mark_needed_node (node); node = next; } /* Make sure we mark alias targets as used targets. */ finish_aliases_1 (); varpool_analyze_pending_decls (); }
/* Output all variables enqueued to be assembled. */ bool varpool_assemble_pending_decls (void) { bool changed = false; if (seen_error ()) return false; timevar_push (TV_VAROUT); /* 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; if (varpool_assemble_decl (node)) changed = true; else { node->prev_needed = NULL; 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; timevar_pop (TV_VAROUT); return changed; }
/* Optimization of function bodies might've rendered some variables as unnecessary so we want to avoid these from being compiled. This is done by pruning the queue and keeping only the variables that really appear needed (ie they are either externally visible or referenced by compiled function). Re-doing the reachability analysis on variables brings back the remaining variables referenced by these. */ void varpool_remove_unreferenced_decls (void) { struct varpool_node *next, *node = varpool_nodes_queue; varpool_reset_queue (); if (errorcount || sorrycount) return; while (node) { tree decl = node->decl; next = node->next_needed; node->needed = 0; if (node->finalized && (decide_is_variable_needed (node, decl) /* ??? Cgraph does not yet rule the world with an iron hand, and does not control the emission of debug information. After a variable has its DECL_RTL set, we must assume that it may be referenced by the debug information, and we can no longer elide it. */ || DECL_RTL_SET_P (decl))) varpool_mark_needed_node (node); node = next; } /* Make sure we mark alias targets as used targets. */ finish_aliases_1 (); varpool_analyze_pending_decls (); }
/* 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; }