From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 659 invoked by alias); 26 Jun 2009 19:24:46 -0000 Received: (qmail 605 invoked by uid 22791); 26 Jun 2009 19:24:45 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Jun 2009 19:24:38 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 913715D428A; Fri, 26 Jun 2009 22:56:27 +0400 (MSD) Received: from endeed2.ispras.ru (endeed2.ispras.ru [83.149.198.245]) by ispserv.ispras.ru (Postfix) with ESMTP id E9C5D3FC48; Fri, 26 Jun 2009 23:24:35 +0400 (MSD) Date: Fri, 26 Jun 2009 19:28:00 -0000 From: Alexander Monakov To: Joe Buck cc: Jeff Law , Richard Guenther , GCC Subject: Re: (known?) Issue with bitmap iterators In-Reply-To: <20090626163559.GM14794@synopsys.com> Message-ID: References: <4A3CF81C.7050406@redhat.com> <84fc9c000906200801v28f814cj3fa5327c5f3df35e@mail.gmail.com> <4A3FBA1E.6040502@redhat.com> <20090622174623.GA6603@synopsys.com> <4A43C0F3.30503@redhat.com> <20090626163559.GM14794@synopsys.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg00626.txt.bz2 On Fri, 26 Jun 2009, Joe Buck wrote: > On Fri, Jun 26, 2009 at 03:38:31AM -0700, Alexander Monakov wrote: >> 1. Add bool field `modified_p' in bitmap structure. >> 2. Make iterator setup functions (e.g. bmp_iter_set_init) reset it to >> false. >> 3. Make functions that modify the bitmap set it to true. >> 4. Make iterator increment function (e.g. bmp_iter_next) assert >> !modified_p. > > Sorry, it doesn't work. Function foo has a loop that iterates > over a bitmap. During the iteration, it calls a function bar. bar > modifies the bitmap, then iterates over the bitmap. It then returns > to foo, which is in the middle of an iteration, which it continues. > The bitmap has been modified (by bar), but modified_p was reset to > false by the iteration that happened at the end of bar. Good catch, thanks! Let me patch that up a bit: 1. Add int field `generation' in bitmap structure, initialized arbitrarily at bitmap creation time. 2. Make iterator setup functions save initial generation count in the iterator (or generation counts for two bitmaps, if needed). 3. Modify generation count when bitmap is modified (e.g. increment it). 4. Verify that saved and current generations match when incrementing the iterator.