From 7144270e2de7ba4954729c75ca389ed3081134ee Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Fri, 6 Nov 2020 13:30:39 +0100 Subject: [PATCH] Move ipa-refs from ggc to heap. gcc/ChangeLog: * ipa-ref.h (enum ipa_ref_use): Remove GTY marker. (struct ipa_ref): Remove GTY marker; reorder for better packing. (struct ipa_ref_list): Remove GTY marker; turn references nad referring to va_heap, vl_ptr vectors; update accesors. * cgraph.h (symtab_node::iterate_reference): Update. * ipa-ref.c (ipa_ref::remove_reference): Update. * symtab.c (symtab_node::create_reference): Update. (symtab_node::remove_all_references): Update. (symtab_node::resolve_alias): Update. gcc/cp/ChangeLog: * tree.c (cp_fix_function_decl_p): Do not access ipa_ref_list dirrectly. --- gcc/cgraph.h | 6 +++--- gcc/cp/tree.c | 3 +-- gcc/ipa-ref.c | 6 ++---- gcc/ipa-ref.h | 21 ++++++++++----------- gcc/symtab.c | 17 ++++++++--------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index c87180f1e96..73c37d8807d 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -221,7 +221,7 @@ public: /* Get number of references for this node. */ inline unsigned num_references (void) { - return ref_list.references ? ref_list.references->length () : 0; + return ref_list.references.length (); } /* Iterates I-th reference in the list, REF is also set. */ @@ -604,7 +604,7 @@ public: symtab_node *same_comdat_group; /* Vectors of referring and referenced entities. */ - ipa_ref_list ref_list; + ipa_ref_list GTY((skip)) ref_list; /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer depending to what was known to frontend on the creation time. @@ -2676,7 +2676,7 @@ symtab_node::next_defined_symbol (void) inline ipa_ref * symtab_node::iterate_reference (unsigned i, ipa_ref *&ref) { - vec_safe_iterate (ref_list.references, i, &ref); + ref_list.references.iterate (i, &ref); return ref; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 63ce9acd7a6..28e591086b3 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -5719,8 +5719,7 @@ cp_fix_function_decl_p (tree decl) /* Don't fix same_body aliases. Although they don't have their own CFG, they share it with what they alias to. */ - if (!node || !node->alias - || !vec_safe_length (node->ref_list.references)) + if (!node || !node->alias || !node->num_references ()) return true; } diff --git a/gcc/ipa-ref.c b/gcc/ipa-ref.c index 241828ee973..b7217c427f2 100644 --- a/gcc/ipa-ref.c +++ b/gcc/ipa-ref.c @@ -32,7 +32,6 @@ ipa_ref::remove_reference () { struct ipa_ref_list *list = referred_ref_list (); struct ipa_ref_list *list2 = referring_ref_list (); - vec *old_references = list2->references; struct ipa_ref *last; gcc_assert (list->referring[referred_index] == this); @@ -66,7 +65,7 @@ ipa_ref::remove_reference () } list->referring.pop (); - last = &list2->references->last (); + last = &list2->references.last (); struct ipa_ref *ref = this; @@ -75,8 +74,7 @@ ipa_ref::remove_reference () *ref = *last; ref->referred_ref_list ()->referring[referred_index] = ref; } - list2->references->pop (); - gcc_assert (list2->references == old_references); + list2->references.pop (); } /* Return true when execution of reference can lead to return from diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h index 1de5bd34b82..3ea3f665c3b 100644 --- a/gcc/ipa-ref.h +++ b/gcc/ipa-ref.h @@ -27,7 +27,7 @@ struct symtab_node; /* How the reference is done. */ -enum GTY(()) ipa_ref_use +enum ipa_ref_use { IPA_REF_LOAD, IPA_REF_STORE, @@ -36,7 +36,7 @@ enum GTY(()) ipa_ref_use }; /* Record of reference in callgraph or varpool. */ -struct GTY(()) ipa_ref +struct ipa_ref { public: /* Remove reference. */ @@ -59,28 +59,27 @@ public: symtab_node *referred; gimple *stmt; unsigned int lto_stmt_uid; + unsigned int referred_index; /* speculative id is used to link direct calls with their corresponding IPA_REF_ADDR references when representing speculative calls. */ unsigned int speculative_id : 16; - unsigned int referred_index; ENUM_BITFIELD (ipa_ref_use) use:3; unsigned int speculative:1; }; typedef struct ipa_ref ipa_ref_t; -typedef struct ipa_ref *ipa_ref_ptr; /* List of references. This is stored in both callgraph and varpool nodes. */ -struct GTY(()) ipa_ref_list +struct ipa_ref_list { public: /* Return first reference in list or NULL if empty. */ struct ipa_ref *first_reference (void) { - if (!vec_safe_length (references)) + if (!references.length ()) return NULL; - return &(*references)[0]; + return &references[0]; } /* Return first referring ref in list or NULL if empty. */ @@ -121,20 +120,20 @@ public: void clear (void) { referring.create (0); - references = NULL; + references.create (0); } /* Return number of references. */ unsigned int nreferences (void) { - return vec_safe_length (references); + return references.length (); } /* Store actual references in references vector. */ - vec *references; + vec references; /* Referring is vector of pointers to references. It must not live in GGC space or GGC will try to mark middle of references vectors. */ - vec GTY((skip)) referring; + vec referring; }; #endif /* GCC_IPA_REF_H */ diff --git a/gcc/symtab.c b/gcc/symtab.c index 8ce1c063566..58b14f321c5 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -592,10 +592,9 @@ symtab_node::create_reference (symtab_node *referred_node, gcc_checking_assert (use_type != IPA_REF_ALIAS || !stmt); list = &ref_list; - old_references = vec_safe_address (list->references); - vec_safe_grow (list->references, vec_safe_length (list->references) + 1, - true); - ref = &list->references->last (); + old_references = list->references.address (); + list->references.safe_grow (list->references.length () + 1, false); + ref = &list->references.last (); list2 = &referred_node->ref_list; @@ -623,7 +622,7 @@ symtab_node::create_reference (symtab_node *referred_node, ref->speculative = 0; /* If vector was moved in memory, update pointers. */ - if (old_references != list->references->address ()) + if (old_references != list->references.address ()) { int i; for (i = 0; iterate_reference(i, ref2); i++) @@ -786,9 +785,9 @@ symtab_node::clear_stmts_in_references (void) void symtab_node::remove_all_references (void) { - while (vec_safe_length (ref_list.references)) - ref_list.references->last ().remove_reference (); - vec_free (ref_list.references); + while (ref_list.references.length ()) + ref_list.references.last ().remove_reference (); + ref_list.references.release (); } /* Remove all referring items in ref list. */ @@ -1774,7 +1773,7 @@ symtab_node::resolve_alias (symtab_node *target, bool transparent) { symtab_node *n; - gcc_assert (!analyzed && !vec_safe_length (ref_list.references)); + gcc_assert (!analyzed && !ref_list.references.length ()); /* Never let cycles to creep into the symbol table alias references; those will make alias walkers to be infinite. */ -- 2.30.2