From patchwork Wed May 27 13:56:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 477145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3EB8E14012C for ; Thu, 28 May 2015 00:17:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=YSTcU9uO; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= TmK4Ny1A2b60rIc0W4YCA++3DIJQKFsCFBRaFlKLP9qxF/QpDWvidWkVUBDV6KzC X2hn4ZpJaRwlQUN3rwcw8iPznpEDF8Xu9h5+2qp8AER4yqywBLQ+y6ynRX5OS8/q V7O0D7rS/RkYyQqu/VZoSiQkVRJB/ja35hHlJGc8vc8= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=5HXN GpxzdqPFmknvWBDncIF+E6Q=; b=YSTcU9uOPf1mlGdzaldW5+KkSo0fQe/onxpS j0ExZYW06C3neOymUvw+fuUe3ajV5wHFibSAecTpSAj+BhKi0FIkWRiUzwC7Zgo9 fhxhlYQsU+VL64VI0Frg9YqhH3J4IPxDvGpAeq9cr31yPY36QYi3yQ+KVG2HCCSH 6v9cKkw= Received: (qmail 84653 invoked by alias); 27 May 2015 14:16:35 -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 84493 invoked by uid 89); 27 May 2015 14:16:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, UNWANTED_LANGUAGE_BODY autolearn=no version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 27 May 2015 14:16:31 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxbsJ-0007KG-Gm for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:11 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57535 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxbsJ-0007Gt-6v for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:03 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 90E15ADFE for ; Wed, 27 May 2015 13:59:57 +0000 (UTC) Resent-From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= Resent-To: GCC Patches Resent-Date: Wed, 27 May 2015 15:59:57 +0200 Resent-Message-ID: <5565CDDD.1030603@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 Message-Id: In-Reply-To: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz> References: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz> From: mliska Date: Wed, 27 May 2015 15:56:49 +0200 Subject: [PATCH 16/35] Change use to type-based pool allocator in tree-sra.c. To: gcc-patches@gcc.gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-IsSubscribed: yes gcc/ChangeLog: 2015-04-30 Martin Liska * tree-sra.c (sra_initialize): Use new type-based pool allocator. (sra_deinitialize) Likewise. (create_access_1) Likewise. (build_accesses_from_assign) Likewise. (create_artificial_child_access) Likewise. --- gcc/tree-sra.c | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 4b0d2a8..b5047e7 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -300,13 +300,28 @@ struct access /* Set when we discover that this pointer is not safe to dereference in the caller. */ unsigned grp_not_necessarilly_dereferenced : 1; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove((access *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; typedef struct access *access_p; /* Alloc pool for allocating access structures. */ -static alloc_pool access_pool; +pool_allocator access::pool ("SRA accesses", 16); /* A structure linking lhs and rhs accesses from an aggregate assignment. They are used to propagate subaccesses from rhs to lhs as long as they don't @@ -315,10 +330,25 @@ struct assign_link { struct access *lacc, *racc; struct assign_link *next; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove((assign_link *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; /* Alloc pool for allocating assign link structures. */ -static alloc_pool link_pool; +pool_allocator assign_link::pool ("SRA links", 16); /* Base (tree) -> Vector (vec *) map. */ static hash_map > *base_access_vec; @@ -690,8 +720,6 @@ sra_initialize (void) should_scalarize_away_bitmap = BITMAP_ALLOC (NULL); cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL); gcc_obstack_init (&name_obstack); - access_pool = create_alloc_pool ("SRA accesses", sizeof (struct access), 16); - link_pool = create_alloc_pool ("SRA links", sizeof (struct assign_link), 16); base_access_vec = new hash_map >; memset (&sra_stats, 0, sizeof (sra_stats)); encountered_apply_args = false; @@ -709,8 +737,8 @@ sra_deinitialize (void) candidates = NULL; BITMAP_FREE (should_scalarize_away_bitmap); BITMAP_FREE (cannot_scalarize_away_bitmap); - free_alloc_pool (access_pool); - free_alloc_pool (link_pool); + access::pool.release (); + assign_link::pool.release (); obstack_free (&name_obstack, NULL); delete base_access_vec; @@ -862,9 +890,8 @@ mark_parm_dereference (tree base, HOST_WIDE_INT dist, gimple stmt) static struct access * create_access_1 (tree base, HOST_WIDE_INT offset, HOST_WIDE_INT size) { - struct access *access; + struct access *access = new struct access(); - access = (struct access *) pool_alloc (access_pool); memset (access, 0, sizeof (struct access)); access->base = base; access->offset = offset; @@ -1239,7 +1266,7 @@ build_accesses_from_assign (gimple stmt) { struct assign_link *link; - link = (struct assign_link *) pool_alloc (link_pool); + link = new assign_link; memset (link, 0, sizeof (struct assign_link)); link->lacc = lacc; @@ -2393,13 +2420,12 @@ static struct access * create_artificial_child_access (struct access *parent, struct access *model, HOST_WIDE_INT new_offset) { - struct access *access; struct access **child; tree expr = parent->base; gcc_assert (!model->grp_unscalarizable_region); - access = (struct access *) pool_alloc (access_pool); + struct access *access = new struct access (); memset (access, 0, sizeof (struct access)); if (!build_user_friendly_ref_for_offset (&expr, TREE_TYPE (expr), new_offset, model->type))