From patchwork Tue Oct 15 12:17:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1176992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511012-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="F/3YC16e"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46svZZ2f6zz9sPT for ; Tue, 15 Oct 2019 23:17:39 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=UDZSdq/wCrp+beXm8EItpsbIf91SdYhKvNbbxE7YBdwHajcmoN YqNIEOeSVKz6+wcQ04zJc6yrFwp/+CTsk58Y9s1sTpKiE99xKXzlCDuVTXNLVpto nqLK4obR40MFGHnRdWoBBLJJ2A8nFdnMNVRMmewtr66xJS85eos1dtEG0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=21HrtKcLzAnvnQlQFODP25VEbw4=; b=F/3YC16ewpzi528qNFL0 +dq0wANhnvfzW8nnj6b0WYIpiqU73PalMo35C62cI4VT+TvgQK5KX+0WMaEfKHZ0 FkrYmWDyj9jn6JTe+77ci54OWLWV+rLGBzUNllZT5ioJu97GnrWf0EeU1n28usUq gaiajf25sRkxYgVdXwX3v7U= Received: (qmail 90692 invoked by alias); 15 Oct 2019 12:17:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 90684 invoked by uid 89); 15 Oct 2019 12:17:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=regularly X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Oct 2019 12:17:31 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CB55DB3C1 for ; Tue, 15 Oct 2019 12:17:28 +0000 (UTC) Date: Tue, 15 Oct 2019 14:17:28 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] Avoid writing to trees during streaming Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Honza figured that variably_modified_type_p uses TREE_VISITED to not run into an Ada abdomination. That causes havoc during WPA streaming which happens in multiple forked processes and thus causes a lot of COW faulting and resident memory usage. It also stands in the way of using threads here. LTO bootstrapped and tested on x86_64-unknown-linux-gnu. Honza - does this look OK? Thanks, Richard. 2019-10-15 Richard Biener * lto-streamer-out.c (lto_variably_modified_type_p): New. (tree_is_indexable): Use it. * tree-streamer-out.c (pack_ts_type_common_value_fields): Stream variably_modified_type_p as TYPE_LANG_FLAG_0. * tree-streamer-in.c (unpack_ts_type_common_value_fields): Likewise. Index: gcc/lto-streamer-out.c =================================================================== --- gcc/lto-streamer-out.c (revision 276985) +++ gcc/lto-streamer-out.c (working copy) @@ -120,6 +120,17 @@ output_type_ref (struct output_block *ob lto_output_type_ref_index (ob->decl_state, ob->main_stream, node); } +/* Wrapper around variably_modified_type_p avoiding type modification + during WPA streaming. */ + +static bool +lto_variably_modified_type_p (tree type) +{ + return (in_lto_p + ? TYPE_LANG_FLAG_0 (TYPE_MAIN_VARIANT (type)) + : variably_modified_type_p (type, NULL_TREE)); +} + /* Return true if tree node T is written to various tables. For these nodes, we sometimes want to write their phyiscal representation @@ -134,7 +145,7 @@ tree_is_indexable (tree t) definition. */ if ((TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL) && DECL_CONTEXT (t)) - return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE); + return lto_variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t))); /* IMPORTED_DECL is put into BLOCK and thus it never can be shared. We should no longer need to stream it. */ else if (TREE_CODE (t) == IMPORTED_DECL) @@ -154,10 +165,10 @@ tree_is_indexable (tree t) them we have to localize their members as well. ??? In theory that includes non-FIELD_DECLs as well. */ else if (TYPE_P (t) - && variably_modified_type_p (t, NULL_TREE)) + && lto_variably_modified_type_p (t)) return false; else if (TREE_CODE (t) == FIELD_DECL - && variably_modified_type_p (DECL_CONTEXT (t), NULL_TREE)) + && lto_variably_modified_type_p (DECL_CONTEXT (t))) return false; else return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME); Index: gcc/tree-streamer-in.c =================================================================== --- gcc/tree-streamer-in.c (revision 276985) +++ gcc/tree-streamer-in.c (working copy) @@ -378,6 +378,7 @@ unpack_ts_type_common_value_fields (stru TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1); + TYPE_LANG_FLAG_0 (expr) = (unsigned) bp_unpack_value (bp, 1); if (RECORD_OR_UNION_TYPE_P (expr)) { TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1); Index: gcc/tree-streamer-out.c =================================================================== --- gcc/tree-streamer-out.c (revision 276985) +++ gcc/tree-streamer-out.c (working copy) @@ -326,6 +326,12 @@ pack_ts_type_common_value_fields (struct bp_pack_value (bp, TYPE_RESTRICT (expr), 1); bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); bp_pack_value (bp, TYPE_READONLY (expr), 1); + unsigned vla_p; + if (in_lto_p) + vla_p = TYPE_LANG_FLAG_0 (TYPE_MAIN_VARIANT (expr)); + else + vla_p = variably_modified_type_p (expr, NULL_TREE); + bp_pack_value (bp, vla_p, 1); /* We used to stream TYPE_ALIAS_SET == 0 information to let frontends mark types that are opaque for TBAA. This however did not work as intended, because TYPE_ALIAS_SET == 0 was regularly lost in type merging. */