From patchwork Wed Mar 6 23:04:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 225676 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 059FC2C038E for ; Thu, 7 Mar 2013 10:05:37 +1100 (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=1363215938; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=PQUSrjA mvd9p2Sb+w2OIi0hQSMo=; b=Xyk7w4JEo01utmB4zuBdznFEHTp4ItCbo9OxCLC mZ+EKn3/daW97dulhZHzIiesRrOCbekjeBIktDOGPoh0TJdxQKNlCZnMCglo2ra8 ilcGqnm6uqJC05EfeWnqEVt935I39c5hgzQ7bERs4DehVMOPU+YbeKj9AalERDZs AYQs= 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:X-Received:MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=WHToV/V+wXNB0EUKuEtgarQ8F4jOdQcMBoSiC2cb0fERAI2jEeFjIUqoTyfexK Br5JMdkwt6c28VmIHGZ+lhL7xYRCUH+9QyQniWkvO6PDFMf/RoCEfUovHF3gfHHa 3giE6penontE3q22qnaLkaiSVcVeSZM789NhB/ohEumdA=; Received: (qmail 14924 invoked by alias); 6 Mar 2013 23:05:13 -0000 Received: (qmail 14813 invoked by uid 22791); 6 Mar 2013 23:05:10 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-vb0-f51.google.com (HELO mail-vb0-f51.google.com) (209.85.212.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Mar 2013 23:05:05 +0000 Received: by mail-vb0-f51.google.com with SMTP id fq11so1877023vbb.38 for ; Wed, 06 Mar 2013 15:05:04 -0800 (PST) X-Received: by 10.220.8.75 with SMTP id g11mr11914797vcg.60.1362611104463; Wed, 06 Mar 2013 15:05:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.58.237.1 with HTTP; Wed, 6 Mar 2013 15:04:23 -0800 (PST) From: Steven Bosscher Date: Thu, 7 Mar 2013 00:04:23 +0100 Message-ID: Subject: [patch] minor bitmap.c GATHER_STATISTICS fix-ups To: GCC Patches Cc: Richard Biener 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 Hello, This patch fixes a bunch of smaller issues with GATHER_STATISTICS for bitmaps: overflows in counters and ugly output format. Bootstrapped (with and without GATHER_STATISTICS) and regtested on powerpc64-unknown-linux-gnu and on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven * bitmap.c (struct bitmap_descriptor_d): Use unsigned HOST_WIDEST_INT for all counters. (struct output_info): Likewise. (register_overhead): Remove bad gcc_assert. (bitmap_find_bit): If there is only a single bitmap element, do not count a miss as a search. (print_statistics): Update for counter type changes. (dump_bitmap_statistics): Likewise. Print headers such that they are properly lined up with the printed counters. * bitmap.c (struct bitmap_descriptor_d): Use unsigned HOST_WIDEST_INT for all counters. (struct output_info): Likewise. (register_overhead): Remove bad gcc_assert. (bitmap_find_bit): If there is only a single bitmap element, do not count a miss as a search. (print_statistics): Update for counter type changes. (dump_bitmap_statistics): Likewise. Print headers such that they are properly lined up with the printed counters. Index: bitmap.c =================================================================== --- bitmap.c (revision 196508) +++ bitmap.c (working copy) @@ -34,11 +34,11 @@ struct bitmap_descriptor_d const char *file; int line; int created; - HOST_WIDEST_INT allocated; - HOST_WIDEST_INT peak; - HOST_WIDEST_INT current; - int nsearches; - int search_iter; + unsigned HOST_WIDEST_INT allocated; + unsigned HOST_WIDEST_INT peak; + unsigned HOST_WIDEST_INT current; + unsigned HOST_WIDEST_INT nsearches; + unsigned HOST_WIDEST_INT search_iter; }; typedef struct bitmap_descriptor_d *bitmap_descriptor; @@ -121,7 +121,6 @@ register_overhead (bitmap b, int amount) desc->current += amount; if (amount > 0) desc->allocated += amount; - gcc_assert (desc->current >= 0); if (desc->peak < desc->current) desc->peak = desc->current; } @@ -565,10 +564,15 @@ bitmap_find_bit (bitmap head, unsigned int bit) bitmap_element *element; unsigned int indx = bit / BITMAP_ELEMENT_ALL_BITS; - if (head->current == 0 + if (head->current == NULL || head->indx == indx) return head->current; + if (head->current == head->first + && head->first->next == NULL) + return NULL; + /* This bitmap has more than one element, and we're going to look + through the elements list. Count that as a search. */ if (GATHER_STATISTICS) bitmap_descriptors[head->descriptor_id]->nsearches++; @@ -2132,8 +2136,8 @@ bitmap_print (FILE *file, const_bitmap head, const /* Used to accumulate statistics about bitmap sizes. */ struct output_info { - HOST_WIDEST_INT size; - int count; + unsigned HOST_WIDEST_INT size; + unsigned HOST_WIDEST_INT count; }; /* Called via htab_traverse. Output bitmap descriptor pointed out by SLOT @@ -2153,10 +2157,14 @@ print_statistics (void **slot, void *b) s1 = s2 + 4; sprintf (s, "%s:%i (%s)", s1, d->line, d->function); s[41] = 0; - fprintf (stderr, "%-41s %8d %15"HOST_WIDEST_INT_PRINT"d %15" - HOST_WIDEST_INT_PRINT"d %15"HOST_WIDEST_INT_PRINT"d %10d %10d\n", - s, d->created, d->allocated, d->peak, d->current, d->nsearches, - d->search_iter); + fprintf (stderr, + "%-41s %9u" + " %15"HOST_WIDEST_INT_PRINT"d %15"HOST_WIDEST_INT_PRINT"d" + " %15"HOST_WIDEST_INT_PRINT"d" + " %10"HOST_WIDEST_INT_PRINT"d %10"HOST_WIDEST_INT_PRINT"d\n", + s, d->created, + d->allocated, d->peak, d->current, + d->nsearches, d->search_iter); i->size += d->allocated; i->count += d->created; } @@ -2175,15 +2183,18 @@ dump_bitmap_statistics (void) if (!bitmap_desc_hash) return; - fprintf (stderr, "\nBitmap Overall " - " Allocated Peak Leak searched " - " search itr\n"); + fprintf (stderr, + "\n%-41s %9s %15s %15s %15s %10s %10s\n", + "Bitmap", "Overall", + "Allocated", "Peak", "Leak", + "searched", "search_itr"); fprintf (stderr, "---------------------------------------------------------------------------------\n"); info.count = 0; info.size = 0; htab_traverse (bitmap_desc_hash, print_statistics, &info); fprintf (stderr, "---------------------------------------------------------------------------------\n"); - fprintf (stderr, "%-40s %9d %15"HOST_WIDEST_INT_PRINT"d\n", + fprintf (stderr, + "%-41s %9"HOST_WIDEST_INT_PRINT"d %15"HOST_WIDEST_INT_PRINT"d\n", "Total", info.count, info.size); fprintf (stderr, "---------------------------------------------------------------------------------\n"); }