From patchwork Sun Aug 19 18:30:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitrios Apostolou X-Patchwork-Id: 178580 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]) by ozlabs.org (Postfix) with SMTP id 14F0B2C0094 for ; Mon, 20 Aug 2012 04:31:41 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1346005902; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: User-Agent:MIME-Version:Content-Type:Content-ID:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=4/5flXdDLqMfz23jgAM9cp5kXuk=; b=OXO9dP2fXZDc0i/gbuK/PLOEbAWAO6Ze689XIWLlG5z1HrpfmaQUJb3D75YbW3 RIUsRZGp5ndfhS1S2B1ofMocNlTEg2UlX0RVZLFbOflb/ut6y2OGrRK0PMBXY7U/ YhQKeYyE+Nqj24PABjstLsCb+PmgerewabfEuGlTzYyz8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:User-Agent:MIME-Version:Content-Type:Content-ID:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ftlq1fADUui1MmLVyu6fJfRORmqTaVjMWLPDVR6+9Ri84UMyVx7XJlof831N5c tAW4ettavprOrFbUfynFeVXtuh6wfjeJmIsLYb5bAgo1l1VWZiDlV2b/2EyiVy+B 1vcrSdttpGSXDz0SRkYzQu/oFoEakU3zWHks1xAKODPdA=; Received: (qmail 10105 invoked by alias); 19 Aug 2012 18:30:56 -0000 Received: (qmail 9990 invoked by uid 22791); 19 Aug 2012 18:30:54 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sun, 19 Aug 2012 18:30:40 +0000 Received: (qmail invoked by alias); 19 Aug 2012 18:30:39 -0000 Received: from teras.ics.forth.gr (EHLO teras.ics.forth.gr) [139.91.70.93] by mail.gmx.net (mp071) with SMTP; 19 Aug 2012 20:30:39 +0200 Date: Sun, 19 Aug 2012 21:30:37 +0300 (EEST) From: Dimitrios Apostolou To: gcc-patches@gcc.gnu.org cc: Andrey Belevantsev Subject: alloc_pool for tree-ssa-pre.c:phi_translate_table In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-ID: X-IsSubscribed: yes 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 2012-08-19 Dimitrios Apostolou * gcc/tree-ssa-pre.c (phi_translate_pool): New static global alloc_pool, used for allocating struct expr_pred_trans_d for phi_translate_table. (phi_trans_add, init_pre, fini_pre): Use it, avoids thousand of malloc() and free() calls. This avoids lots of malloc/free calls and slow iterations during numerous htab_delete() in fini_pre(). Tested on pre C++-snapshot, will update info as soon as a post C++ one is available. Thanks, Dimitris 2012-08-19 Dimitrios Apostolou * gcc/tree-ssa-pre.c (phi_translate_pool): New static global alloc_pool, used for allocating struct expr_pred_trans_d for phi_translate_table. (phi_trans_add, init_pre, fini_pre): Use it, avoids thousand of malloc() and free() calls. === modified file 'gcc/tree-ssa-pre.c' --- gcc/tree-ssa-pre.c 2012-08-17 08:03:54 +0000 +++ gcc/tree-ssa-pre.c 2012-08-18 16:43:02 +0000 @@ -486,7 +486,7 @@ static bitmap need_ab_cleanup; /* A three tuple {e, pred, v} used to cache phi translations in the phi_translate_table. */ -typedef struct expr_pred_trans_d : typed_free_remove +typedef struct expr_pred_trans_d : typed_noop_remove { /* The expression. */ pre_expr e; @@ -508,6 +508,12 @@ typedef struct expr_pred_trans_d : typed } *expr_pred_trans_t; typedef const struct expr_pred_trans_d *const_expr_pred_trans_t; +/* Pool of memory for the above */ + +static alloc_pool phi_translate_pool; + +/* Return the hash value for a phi translation table entry. */ + inline hashval_t expr_pred_trans_d::hash (const expr_pred_trans_d *e) { @@ -561,7 +567,8 @@ static inline void phi_trans_add (pre_expr e, pre_expr v, basic_block pred) { expr_pred_trans_t *slot; - expr_pred_trans_t new_pair = XNEW (struct expr_pred_trans_d); + expr_pred_trans_t new_pair = + (expr_pred_trans_t) pool_alloc (phi_translate_pool); new_pair->e = e; new_pair->pred = pred; new_pair->v = v; @@ -570,7 +577,8 @@ phi_trans_add (pre_expr e, pre_expr v, b slot = phi_translate_table.find_slot_with_hash (new_pair, new_pair->hashcode, INSERT); - free (*slot); + if (*slot) + pool_free (phi_translate_pool, *slot); *slot = new_pair; } @@ -4798,6 +4806,9 @@ init_pre (bool do_fre) calculate_dominance_info (CDI_DOMINATORS); bitmap_obstack_initialize (&grand_bitmap_obstack); + phi_translate_pool = create_alloc_pool ("phi_translate_table", + sizeof (struct expr_pred_trans_d), + 512); phi_translate_table.create (5110); expression_to_id.create (num_ssa_names * 3); bitmap_set_pool = create_alloc_pool ("Bitmap sets", @@ -4832,6 +4843,7 @@ fini_pre (bool do_fre) free_alloc_pool (bitmap_set_pool); free_alloc_pool (pre_expr_pool); phi_translate_table.dispose (); + free_alloc_pool (phi_translate_pool); expression_to_id.dispose (); VEC_free (unsigned, heap, name_to_id);