From patchwork Wed May 27 13:56:44 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: 477124 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 30F4C1400B7 for ; Thu, 28 May 2015 00:00: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=n2JmPf3T; 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= W0GMRcPuEfj4/9czTSCTbNcFbyKcPKWQ/Cfs+elsQ/6U0lLhp0vuNFJ69WWmxa8Q n62e8FGL83cl0bHcQAVuI4VengjPpcxXp1ZhlOGA/sJv4F8VHtW3gDTY5KDLmpAR g61hWsNy51hl3tQI8fpgpoLl+QqVznFMMVOXmScguDk= 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=0qOO 2a4SIXJCvDpnbgqtZn6cri0=; b=n2JmPf3TnvOeV3LcuhnvuWci4Qf1jtyo1NO3 qooojs3CysVg8j0iWi1E4Z1ruejnSv+BBBhJs4JwjbwVxXaCBg54P14gBTNFkWph MR4vIzAB3c9pnoGyDPmVpZLXKpHunIKFU5wjtoIhEpJ9uomfhsLUh/BGkUSoX22C lmRPgx4= Received: (qmail 68703 invoked by alias); 27 May 2015 14:00:02 -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 68641 invoked by uid 89); 27 May 2015 14:00:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 27 May 2015 13:59:59 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 90566ADEF for ; Wed, 27 May 2015 13:59:56 +0000 (UTC) Resent-From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= Resent-To: GCC Patches Resent-Date: Wed, 27 May 2015 15:59:56 +0200 Resent-Message-ID: <5565CDDC.40800@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:44 +0200 Subject: [PATCH 03/35] Change use to type-based pool allocator in lra-lives.c. To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/ChangeLog: 2015-04-30 Martin Liska * lra-lives.c (free_live_range): Use new type-based pool allocator. (free_live_range_list) Likewise. (create_live_range) Likewise. (copy_live_range) Likewise. (lra_merge_live_ranges) Likewise. (remove_some_program_points_and_update_live_ranges) Likewise. (lra_live_ranges_init) Likewise. (lra_live_ranges_finish) Likewise. --- gcc/lra-coalesce.c | 1 + gcc/lra-int.h | 15 +++++++++++++++ gcc/lra-lives.c | 27 +++++++-------------------- gcc/lra-spills.c | 1 + gcc/lra.c | 1 + 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c index 045691d..b385603 100644 --- a/gcc/lra-coalesce.c +++ b/gcc/lra-coalesce.c @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "timevar.h" #include "ira.h" +#include "alloc-pool.h" #include "lra-int.h" #include "df.h" diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 12923ee..4bdd2c6 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -54,6 +54,21 @@ struct lra_live_range lra_live_range_t next; /* Pointer to structures with the same start. */ lra_live_range_t start_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((lra_live_range *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; typedef struct lra_copy *lra_copy_t; diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c index 085411e..9b5f74e 100644 --- a/gcc/lra-lives.c +++ b/gcc/lra-lives.c @@ -121,14 +121,7 @@ static sparseset unused_set, dead_set; static bitmap_head temp_bitmap; /* Pool for pseudo live ranges. */ -static alloc_pool live_range_pool; - -/* Free live range LR. */ -static void -free_live_range (lra_live_range_t lr) -{ - pool_free (live_range_pool, lr); -} +pool_allocator lra_live_range::pool ("live ranges", 100); /* Free live range list LR. */ static void @@ -139,7 +132,7 @@ free_live_range_list (lra_live_range_t lr) while (lr != NULL) { next = lr->next; - free_live_range (lr); + delete lr; lr = next; } } @@ -148,9 +141,7 @@ free_live_range_list (lra_live_range_t lr) static lra_live_range_t create_live_range (int regno, int start, int finish, lra_live_range_t next) { - lra_live_range_t p; - - p = (lra_live_range_t) pool_alloc (live_range_pool); + lra_live_range_t p = new lra_live_range; p->regno = regno; p->start = start; p->finish = finish; @@ -162,9 +153,7 @@ create_live_range (int regno, int start, int finish, lra_live_range_t next) static lra_live_range_t copy_live_range (lra_live_range_t r) { - lra_live_range_t p; - - p = (lra_live_range_t) pool_alloc (live_range_pool); + lra_live_range_t p = new lra_live_range; *p = *r; return p; } @@ -209,7 +198,7 @@ lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2) r1->start = r2->start; lra_live_range_t temp = r2; r2 = r2->next; - pool_free (live_range_pool, temp); + delete temp; } else { @@ -1109,7 +1098,7 @@ remove_some_program_points_and_update_live_ranges (void) } prev_r->start = r->start; prev_r->next = next_r; - free_live_range (r); + delete r; } } } @@ -1380,8 +1369,6 @@ lra_clear_live_ranges (void) void lra_live_ranges_init (void) { - live_range_pool = create_alloc_pool ("live ranges", - sizeof (struct lra_live_range), 100); bitmap_initialize (&temp_bitmap, ®_obstack); initiate_live_solver (); } @@ -1392,5 +1379,5 @@ lra_live_ranges_finish (void) { finish_live_solver (); bitmap_clear (&temp_bitmap); - free_alloc_pool (live_range_pool); + lra_live_range::pool.release (); } diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c index 19ece20..caece9a 100644 --- a/gcc/lra-spills.c +++ b/gcc/lra-spills.c @@ -98,6 +98,7 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "timevar.h" #include "target.h" +#include "alloc-pool.h" #include "lra-int.h" #include "ira.h" #include "df.h" diff --git a/gcc/lra.c b/gcc/lra.c index 7c33636..7440668 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -149,6 +149,7 @@ along with GCC; see the file COPYING3. If not see #include "timevar.h" #include "target.h" #include "ira.h" +#include "alloc-pool.h" #include "lra-int.h" #include "df.h"