From patchwork Thu Oct 29 15:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1390233 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 4CMVKM6Lcwz9sSG for ; Fri, 30 Oct 2020 02:51:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4033E3854835; Thu, 29 Oct 2020 15:50: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 D10F63854830 for ; Thu, 29 Oct 2020 15:50:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D10F63854830 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 7F1AA28115E; Thu, 29 Oct 2020 16:50:54 +0100 (CET) Date: Thu, 29 Oct 2020 16:50:54 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Avoid char[] array in tree_def Message-ID: <20201029155054.GA54974@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.8 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 removes second char array from tree_def union and makes it !TYPELESS_STORAGE. Now all accesses to anything in tree no longer have alias set 0, but they all have alias set 1 :) This is because the way we handle unions. However it still increases TBAA effectivity by about 12%. From: Alias oracle query stats: refs_may_alias_p: 65066258 disambiguations, 74846942 queries ref_maybe_used_by_call_p: 152444 disambiguations, 65966862 queries call_may_clobber_ref_p: 22546 disambiguations, 28559 queries nonoverlapping_component_refs_p: 0 disambiguations, 36816 queries nonoverlapping_refs_since_match_p: 27230 disambiguations, 58300 must overlaps, 86300 queries aliasing_component_refs_p: 66090 disambiguations, 2048800 queries TBAA oracle: 25578632 disambiguations 59483650 queries 12219919 are in alias set 0 10534575 queries asked about the same object 125 queries asked about the same alias set 0 access volatile 9491563 are dependent in the DAG 1658836 are aritificially in conflict with void * Modref stats: modref use: 14421 disambiguations, 48129 queries modref clobber: 1528229 disambiguations, 1926907 queries 3881547 tbaa queries (2.014392 per modref query) 565057 base compares (0.293246 per modref query) PTA query stats: pt_solution_includes: 947491 disambiguations, 13119151 queries pt_solutions_intersect: 1043695 disambiguations, 13221495 queries To: Alias oracle query stats: refs_may_alias_p: 66455561 disambiguations, 75202803 queries ref_maybe_used_by_call_p: 155301 disambiguations, 67370278 queries call_may_clobber_ref_p: 22550 disambiguations, 28587 queries nonoverlapping_component_refs_p: 0 disambiguations, 37058 queries nonoverlapping_refs_since_match_p: 28126 disambiguations, 59906 must overlaps, 88990 queries aliasing_component_refs_p: 66375 disambiguations, 2440039 queries TBAA oracle: 28800751 disambiguations 64328055 queries 8053661 are in alias set 0 11181983 queries asked about the same object 125 queries asked about the same alias set 0 access volatile 13905691 are dependent in the DAG 2385844 are aritificially in conflict with void * Modref stats: modref use: 16781 disambiguations, 52031 queries modref clobber: 1745589 disambiguations, 2149518 queries 4192266 tbaa queries (1.950328 per modref query) 559148 base compares (0.260127 per modref query) PTA query stats: pt_solution_includes: 906487 disambiguations, 13105994 queries pt_solutions_intersect: 1041144 disambiguations, 13659726 queries Bootstrapped/regtested x86_64-linux, OK? * tree.c (build_string): Update. * tree-core.h (tree_fixed_cst): Avoid typeless storage. diff --git a/gcc/tree-core.h b/gcc/tree-core.h index c9280a8d3b1..63dbb5b8eab 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1401,7 +1401,8 @@ struct GTY(()) tree_fixed_cst { struct GTY(()) tree_string { struct tree_typed typed; int length; - char str[1]; + /* Avoid char array that would make whole type to be typeless storage. */ + struct {char c;} str[1]; }; struct GTY(()) tree_complex { diff --git a/gcc/tree.c b/gcc/tree.c index 81f867ddded..84115630184 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2273,7 +2273,7 @@ build_string (unsigned len, const char *str /*= NULL */) memcpy (s->string.str, str, len); else memset (s->string.str, 0, len); - s->string.str[len] = '\0'; + s->string.str[len].c = '\0'; return s; }