From patchwork Wed Jun 9 18:56:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 55118 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 D72D81007D1 for ; Thu, 10 Jun 2010 04:56:21 +1000 (EST) Received: (qmail 26528 invoked by alias); 9 Jun 2010 18:56:20 -0000 Received: (qmail 26513 invoked by uid 22791); 9 Jun 2010 18:56:19 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Jun 2010 18:56:15 +0000 Received: from localhost (occam.ms.mff.cuni.cz [195.113.18.121]) by nikam.ms.mff.cuni.cz (Postfix) with ESMTP id E632F9AC037 for ; Wed, 9 Jun 2010 20:56:12 +0200 (CEST) Received: by localhost (Postfix, from userid 16202) id E128D5641AD; Wed, 9 Jun 2010 20:56:12 +0200 (CEST) Date: Wed, 9 Jun 2010 20:56:12 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Asserts in bitmap.c Message-ID: <20100609185612.GA1735@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 Hi, bitmap.c constains quite few asserts, some in internal loops that checks consistency of the datastructure itself. I turned into checking assert all of them that are not guarding operation on the whole bitmap. (i.e. keeping asserts checking that bitmap_and is not used with destination being same as sources and some more global checks). I think the second might go away too, but they are not important. In fact only ones I care about are those in bitmap_elt* functions that are tripped over every time we handle new bitmap page. Bootstrapped/regtested x86_64-linux, OK? Honza * bitmap.c (bitmap_elt_insert_after, bitmap_first_set_bit, bitmap_first_set_bit, bitmap_last_set_bit, bitmap_last_set_bit, bitmap_and_into, bitmap_and_compl_into, bitmap_set_range, bitmap_compl_and_into, bitmap_elt_ior): Use checking asserts; merge multiple asserts into single. Index: bitmap.c =================================================================== --- bitmap.c (revision 160502) +++ bitmap.c (working copy) @@ -499,7 +499,7 @@ bitmap_elt_insert_after (bitmap head, bi } else { - gcc_assert (head->current); + gcc_checking_assert (head->current); node->next = elt->next; if (node->next) node->next->prev = node; @@ -780,7 +780,7 @@ bitmap_first_set_bit (const_bitmap a) BITMAP_WORD word; unsigned ix; - gcc_assert (elt); + gcc_checking_assert (elt); bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS; for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++) { @@ -815,7 +815,7 @@ bitmap_first_set_bit (const_bitmap a) if (!(word & 0x1)) word >>= 1, bit_no += 1; - gcc_assert (word & 1); + gcc_checking_assert (word & 1); #endif return bit_no; } @@ -831,7 +831,7 @@ bitmap_last_set_bit (const_bitmap a) BITMAP_WORD word; int ix; - gcc_assert (elt); + gcc_checking_assert (elt); while (elt->next) elt = elt->next; bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS; @@ -869,7 +869,7 @@ bitmap_last_set_bit (const_bitmap a) word >>= 1, bit_no += 1; #endif - gcc_assert (word & 1); + gcc_checking_assert (word & 1); return bit_no; } @@ -975,8 +975,8 @@ bitmap_and_into (bitmap a, const_bitmap } } bitmap_elt_clear_from (a, a_elt); - gcc_assert (!a->current == !a->first); - gcc_assert (!a->current || a->indx == a->current->indx); + gcc_assert (!a->current == !a->first + && (!a->current || a->indx == a->current->indx)); } @@ -1175,8 +1175,8 @@ bitmap_and_compl_into (bitmap a, const_b b_elt = b_elt->next; } } - gcc_assert (!a->current == !a->first); - gcc_assert (!a->current || a->indx == a->current->indx); + gcc_assert (!a->current == !a->first + && (!a->current || a->indx == a->current->indx)); return changed != 0; } @@ -1207,7 +1207,7 @@ bitmap_set_range (bitmap head, unsigned bitmap_element_link (head, elt); } - gcc_assert (elt->indx == first_index); + gcc_checking_assert (elt->indx == first_index); elt_prev = elt->prev; for (i = first_index; i <= last_index; i++) { @@ -1470,8 +1470,8 @@ bitmap_compl_and_into (bitmap a, const_b b_elt = b_elt->next; } } - gcc_assert (!a->current == !a->first); - gcc_assert (!a->current || a->indx == a->current->indx); + gcc_assert (!a->current == !a->first + && (!a->current || a->indx == a->current->indx)); return; } @@ -1528,7 +1535,7 @@ bitmap_elt_ior (bitmap dst, bitmap_eleme else src = b_elt; - gcc_assert (src); + gcc_checking_assert (src); changed = bitmap_elt_copy (dst, dst_elt, dst_prev, src, changed); } return changed;