DEBUG_FUNCTION bool verify_symtab_base (symtab_node *node) { bool error_found = false; symtab_node *hashed_node; if (is_a <cgraph_node> (node)) { if (TREE_CODE (node->decl) != FUNCTION_DECL) { error ("function symbol is not function"); error_found = true; } } else if (is_a <varpool_node> (node)) { if (TREE_CODE (node->decl) != VAR_DECL) { error ("variable symbol is not variable"); error_found = true; } } else { error ("node has unknown type"); error_found = true; } if (cgraph_state != CGRAPH_LTO_STREAMING) { hashed_node = symtab_get_node (node->decl); if (!hashed_node) { error ("node not found in symtab decl hashtable"); error_found = true; } if (hashed_node != node && (!is_a <cgraph_node> (node) || !dyn_cast <cgraph_node> (node)->clone_of || dyn_cast <cgraph_node> (node)->clone_of->decl != node->decl)) { error ("node differs from symtab decl hashtable"); error_found = true; } } if (assembler_name_hash) { hashed_node = symtab_node_for_asm (DECL_ASSEMBLER_NAME (node->decl)); if (hashed_node && hashed_node->previous_sharing_asm_name) { error ("assembler name hash list corrupted"); error_found = true; } while (hashed_node) { if (hashed_node == node) break; hashed_node = hashed_node->next_sharing_asm_name; } if (!hashed_node && !(is_a <varpool_node> (node) || DECL_HARD_REGISTER (node->decl))) { error ("node not found in symtab assembler name hash"); error_found = true; } } if (node->previous_sharing_asm_name && node->previous_sharing_asm_name->next_sharing_asm_name != node) { error ("double linked list of assembler names corrupted"); error_found = true; } if (node->analyzed && !node->definition) { error ("node is analyzed byt it is not a definition"); error_found = true; } if (node->cpp_implicit_alias && !node->alias) { error ("node is alias but not implicit alias"); error_found = true; } if (node->alias && !node->definition && !node->weakref) { error ("node is alias but not definition"); error_found = true; } if (node->weakref && !node->alias) { error ("node is weakref but not an alias"); error_found = true; } if (node->same_comdat_group) { symtab_node *n = node->same_comdat_group; if (!DECL_ONE_ONLY (n->decl)) { error ("non-DECL_ONE_ONLY node in a same_comdat_group list"); error_found = true; } if (n->type != node->type) { error ("mixing different types of symbol in same comdat groups is not supported"); error_found = true; } if (n == node) { error ("node is alone in a comdat group"); error_found = true; } do { if (!n->same_comdat_group) { error ("same_comdat_group is not a circular list"); error_found = true; break; } n = n->same_comdat_group; } while (n != node); if (symtab_comdat_local_p (node)) { struct ipa_ref_list *refs = &node->ref_list; struct ipa_ref *ref; for (int i = 0; ipa_ref_list_referring_iterate (refs, i, ref); ++i) { if (!symtab_in_same_comdat_p (ref->referring, node)) { error ("comdat-local symbol referred to by %s outside its " "comdat", identifier_to_locale (ref->referring->name())); error_found = true; } } } } return error_found; }
DEBUG_FUNCTION bool symtab_node::verify_base (void) { bool error_found = false; symtab_node *hashed_node; if (is_a <cgraph_node *> (this)) { if (TREE_CODE (decl) != FUNCTION_DECL) { error ("function symbol is not function"); error_found = true; } } else if (is_a <varpool_node *> (this)) { if (TREE_CODE (decl) != VAR_DECL) { error ("variable symbol is not variable"); error_found = true; } } else { error ("node has unknown type"); error_found = true; } if (symtab->state != LTO_STREAMING) { hashed_node = symtab_node::get (decl); if (!hashed_node) { error ("node not found node->decl->decl_with_vis.symtab_node"); error_found = true; } if (hashed_node != this && (!is_a <cgraph_node *> (this) || !dyn_cast <cgraph_node *> (this)->clone_of || dyn_cast <cgraph_node *> (this)->clone_of->decl != decl)) { error ("node differs from node->decl->decl_with_vis.symtab_node"); error_found = true; } } if (symtab->assembler_name_hash) { hashed_node = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (decl)); if (hashed_node && hashed_node->previous_sharing_asm_name) { error ("assembler name hash list corrupted"); error_found = true; } while (hashed_node) { if (hashed_node == this) break; hashed_node = hashed_node->next_sharing_asm_name; } if (!hashed_node && !(is_a <varpool_node *> (this) || DECL_HARD_REGISTER (decl))) { error ("node not found in symtab assembler name hash"); error_found = true; } } if (previous_sharing_asm_name && previous_sharing_asm_name->next_sharing_asm_name != this) { error ("double linked list of assembler names corrupted"); error_found = true; } if (analyzed && !definition) { error ("node is analyzed byt it is not a definition"); error_found = true; } if (cpp_implicit_alias && !alias) { error ("node is alias but not implicit alias"); error_found = true; } if (alias && !definition && !weakref) { error ("node is alias but not definition"); error_found = true; } if (weakref && !alias) { error ("node is weakref but not an alias"); error_found = true; } if (same_comdat_group) { symtab_node *n = same_comdat_group; if (!n->get_comdat_group ()) { error ("node is in same_comdat_group list but has no comdat_group"); error_found = true; } if (n->get_comdat_group () != get_comdat_group ()) { error ("same_comdat_group list across different groups"); error_found = true; } if (!n->definition) { error ("Node has same_comdat_group but it is not a definition"); error_found = true; } if (n->type != type) { error ("mixing different types of symbol in same comdat groups is not supported"); error_found = true; } if (n == this) { error ("node is alone in a comdat group"); error_found = true; } do { if (!n->same_comdat_group) { error ("same_comdat_group is not a circular list"); error_found = true; break; } n = n->same_comdat_group; } while (n != this); if (comdat_local_p ()) { ipa_ref *ref = NULL; for (int i = 0; iterate_referring (i, ref); ++i) { if (!in_same_comdat_group_p (ref->referring)) { error ("comdat-local symbol referred to by %s outside its " "comdat", identifier_to_locale (ref->referring->name())); error_found = true; } } } } if (implicit_section && !get_section ()) { error ("implicit_section flag is set but section isn't"); error_found = true; } if (get_section () && get_comdat_group () && !implicit_section) { error ("Both section and comdat group is set"); error_found = true; } /* TODO: Add string table for sections, so we do not keep holding duplicated strings. */ if (alias && definition && get_section () != get_alias_target ()->get_section () && (!get_section() || !get_alias_target ()->get_section () || strcmp (get_section(), get_alias_target ()->get_section ()))) { error ("Alias and target's section differs"); get_alias_target ()->dump (stderr); error_found = true; } if (alias && definition && get_comdat_group () != get_alias_target ()->get_comdat_group ()) { error ("Alias and target's comdat groups differs"); get_alias_target ()->dump (stderr); error_found = true; } return error_found; }