From patchwork Thu Oct 27 23:32:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 122303 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 8CB5C1007DA for ; Fri, 28 Oct 2011 10:35:06 +1100 (EST) Received: (qmail 14440 invoked by alias); 27 Oct 2011 23:34:58 -0000 Received: (qmail 27591 invoked by uid 22791); 27 Oct 2011 23:32:46 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_00, SPF_NEUTRAL X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 23:32:33 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJZQy-0001Jc-Kn for gcc-patches@gcc.gnu.org; Thu, 27 Oct 2011 19:32:33 -0400 Received: from smtp25.services.sfr.fr ([93.17.128.120]:45614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJZQf-0001HZ-OV; Thu, 27 Oct 2011 19:32:10 -0400 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id F04197000054; Fri, 28 Oct 2011 01:32:08 +0200 (CEST) Received: from gimli.local (145.15.72.86.rev.sfr.net [86.72.15.145]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id B5F7D70000AC; Fri, 28 Oct 2011 01:32:08 +0200 (CEST) X-SFR-UUID: 20111027233208745.B5F7D70000AC@msfrf2512.sfr.fr MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111027233208.18581.37924@gimli.local> In-Reply-To: <20111027233144.18581.30688@gimli.local> References: <20111027232818.18581.901@gimli.local> <20111027233144.18581.30688@gimli.local> Subject: [Patch, fortran] [34/66] inline sum and product: Update the scalarizer: gfc_ss_info refcounting Date: Fri, 28 Oct 2011 01:32:08 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 93.17.128.120 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 As there will be more than one gfc_ss struct pointing to a single gfc_ss_info, it needs to be reference counted. This introduces reference counting. OK? 2011-10-19 Mikael Morin * trans.h (struct gfc_ss_info): New field refcount. * trans-array.c (free_ss_info): Decrement refcount. Return early if still non-zero. (gfc_get_array_ss, gfc_get_temp_ss, gfc_get_scalar_ss): Increment refcount. diff --git a/trans-array.c b/trans-array.c index 663d12e..abb6db2 100644 --- a/trans-array.c +++ b/trans-array.c @@ -489,6 +489,11 @@ gfc_free_ss_chain (gfc_ss * ss) static void free_ss_info (gfc_ss_info *ss_info) { + ss_info->refcount--; + if (ss_info->refcount > 0) + return; + + gcc_assert (ss_info->refcount == 0); free (ss_info); } @@ -532,6 +537,7 @@ gfc_get_array_ss (gfc_ss *next, gfc_expr *expr, int dimen, gfc_ss_type type) int i; ss_info = gfc_get_ss_info (); + ss_info->refcount++; ss_info->type = type; ss_info->expr = expr; @@ -556,6 +562,7 @@ gfc_get_temp_ss (tree type, tree string_length, int dimen) int i; ss_info = gfc_get_ss_info (); + ss_info->refcount++; ss_info->type = GFC_SS_TEMP; ss_info->string_length = string_length; ss_info->data.temp.type = type; @@ -580,6 +587,7 @@ gfc_get_scalar_ss (gfc_ss *next, gfc_expr *expr) gfc_ss_info *ss_info; ss_info = gfc_get_ss_info (); + ss_info->refcount++; ss_info->type = GFC_SS_SCALAR; ss_info->expr = expr; diff --git a/trans.h b/trans.h index c35b1ae..02f2b42 100644 --- a/trans.h +++ b/trans.h @@ -185,6 +185,7 @@ gfc_ss_type; typedef struct gfc_ss_info { + int refcount; gfc_ss_type type; gfc_expr *expr; tree string_length;