From patchwork Wed Nov 20 12:14:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1198086 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514141-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QocjoEWC"; 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 47J1pp4zpjz9s4Y for ; Wed, 20 Nov 2019 23:14:56 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=sq1WC9S6KAsIlDIc0r5GF/FSkQssEaQsk9WlEA0RYUYMYn9ZkDqUj Kn7IOtyosiablHeB9lMn6s751jikrIoLSLJgu/g4g5kljj8xWTd4iSgRKz34290h NyiwBYVyvwZN3hZ/cvYgxeapHYSdgdtYSc38CaH1CosR9gGZBxDIdo= 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:subject:message-id:mime-version:content-type; s= default; bh=BVx1m0VACkfmAxtAm0G62QiBF4U=; b=QocjoEWCaeCnp6dLNbdY atjNx4ldQkNn1ed1+CQB4y8flqecMQPWJgTwe5/HJEF11marZCLPCIQo6h0TyVUM ybkhnV2kw71xyQcgq3pmBc9Lib9Xln1rBkInTL/oin/MZX9z+BvgoYLuFws0wcbC C+z4/C/WAbkMjXzl/+fd4Yg= Received: (qmail 3405 invoked by alias); 20 Nov 2019 12:14:49 -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 3394 invoked by uid 89); 20 Nov 2019 12:14:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=majority X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Nov 2019 12:14:48 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 78611287E36; Wed, 20 Nov 2019 13:14:45 +0100 (CET) Date: Wed, 20 Nov 2019 13:14:45 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Stack allocate DFS::scc_stack and DFS::worklist Message-ID: <20191120121445.bgj7a25krjbmbytp@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, another common (ab)use of malloc/free is the DEF worklist and stack used in streaming out. Since most of SCCs are small, we could easily use stack for them in majority of time. Bootstrapped/regtested x86_64-linux, OK? * lto-streamer-out.c (DFS::sccstack): Turn into auto-vec; preallocate for 32 entries. (DFS::worklist_vec): Likewise. (DFS::DFS): Do not initialize sccstack and worklist. (DFS::~DFS): Do not release sccstack. Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 278464) +++ lto-streamer-out.c (working copy) @@ -514,7 +514,7 @@ public: tree t; hashval_t hash; }; - vec sccstack; + auto_vec sccstack; private: struct sccs @@ -544,7 +544,7 @@ private: bool ref_p, bool this_ref_p); hash_map sccstate; - vec worklist_vec; + auto_vec worklist_vec; struct obstack sccstate_obstack; }; @@ -558,9 +558,7 @@ DFS::DFS (struct output_block *ob, tree bool single_p) { unsigned int next_dfs_num = 1; - sccstack.create (0); gcc_obstack_init (&sccstate_obstack); - worklist_vec = vNULL; DFS_write_tree (ob, NULL, expr, ref_p, this_ref_p); while (!worklist_vec.is_empty ()) { @@ -735,12 +733,10 @@ DFS::DFS (struct output_block *ob, tree from_state->low = MIN (cstate->dfsnum, from_state->low); worklist_vec.pop (); } - worklist_vec.release (); } DFS::~DFS () { - sccstack.release (); obstack_free (&sccstate_obstack, NULL); }