- timevar_push (TV_SYMOUT);
- if (errorcount == 0 && sorrycount == 0)
- while (varpool_assembled_nodes_queue)
- {
- struct varpool_node *node = varpool_assembled_nodes_queue;
-
- /* Local static variables are never seen by check_global_declarations
- so we need to output debug info by hand. */
- if (DECL_CONTEXT (node->decl)
- && (TREE_CODE (DECL_CONTEXT (node->decl)) == BLOCK
- || TREE_CODE (DECL_CONTEXT (node->decl)) == FUNCTION_DECL)
- && errorcount == 0 && sorrycount == 0)
- (*debug_hooks->global_decl) (node->decl);
- varpool_assembled_nodes_queue = node->next_needed;
- node->next_needed = 0;
- }
- timevar_pop (TV_SYMOUT);
+ /* 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;
+}
+
+/* Create a new global variable of type TYPE. */
+tree
+add_new_static_var (tree type)
+{
+ tree new_decl;
+ struct varpool_node *new_node;
+
+ new_decl = create_tmp_var (type, NULL);
+ DECL_NAME (new_decl) = create_tmp_var_name (NULL);
+ TREE_READONLY (new_decl) = 0;
+ TREE_STATIC (new_decl) = 1;
+ TREE_USED (new_decl) = 1;
+ DECL_CONTEXT (new_decl) = NULL_TREE;
+ DECL_ABSTRACT (new_decl) = 0;
+ lang_hooks.dup_lang_specific_decl (new_decl);
+ create_var_ann (new_decl);
+ new_node = varpool_node (new_decl);
+ varpool_mark_needed_node (new_node);
+ add_referenced_var (new_decl);
+ varpool_finalize_decl (new_decl);
+
+ return new_node->decl;
+}
+
+/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
+ Extra name aliases are output whenever DECL is output. */
+
+bool
+varpool_extra_name_alias (tree alias, tree decl)
+{
+ struct varpool_node key, *alias_node, *decl_node, **slot;
+
+#ifndef ASM_OUTPUT_DEF
+ /* If aliases aren't supported by the assembler, fail. */
+ return false;
+#endif
+
+ gcc_assert (TREE_CODE (decl) == VAR_DECL);
+ gcc_assert (TREE_CODE (alias) == VAR_DECL);
+ /* Make sure the hash table has been created. */
+ decl_node = varpool_node (decl);
+
+ key.decl = alias;
+
+ slot = (struct varpool_node **) htab_find_slot (varpool_hash, &key, INSERT);
+
+ /* If the varpool_node has been already created, fail. */
+ if (*slot)
+ return false;
+
+ alias_node = GGC_CNEW (struct varpool_node);
+ alias_node->decl = alias;
+ alias_node->alias = 1;
+ alias_node->extra_name = decl_node;
+ alias_node->next = decl_node->extra_name;
+ decl_node->extra_name = alias_node;
+ *slot = alias_node;
+ return true;