From patchwork Fri Nov 6 11:49:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1395639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CSJbd1hxhz9s0b for ; Fri, 6 Nov 2020 22:50:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AF8B3A5303C; Fri, 6 Nov 2020 11:49:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 12305385702D for ; Fri, 6 Nov 2020 11:49:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 12305385702D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 6B4B72810F4; Fri, 6 Nov 2020 12:49:50 +0100 (CET) Date: Fri, 6 Nov 2020 12:49:50 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Move ipa-refs from GC to heap Message-ID: <20201106114950.GC65107@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch moves ipa-refs from ggc to heap. They are half in heap anyway (so they can not go to PCH) and thus finishing it easy and makes code also bit cleaner. While refs points to statements all those statements are also reachable from function bodies. Bootstrapped/regtested x86_64-linux. gcc/ChangeLog: 2020-11-06 Jan Hubicka * 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: 2020-11-06 Jan Hubicka * tree.c (cp_fix_function_decl_p): Do not access ipa_ref_list dirrectly. 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. */