From patchwork Sat Feb 16 10:08:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 220955 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 585722C008E for ; Sat, 16 Feb 2013 21:08:39 +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=1361614120; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=QEZlnwS2dYw0GaWebfK4OI8iGcE=; b=WoUUKkBBfG9IQwSAbQEM8GwfVMPvyEhZ2ByNt268S1ZoaSbTu5fhDW3HTEuSaA /cpGbQhram8a+ifabfL2y+xUs5wcxdfJE8q198sy+/FswGp8AgRKCH4y/Ezgb74W Rf/2rXDaLDY1xiWPKLgIud5MlTFSf5ciC1+SIdosIfBiU= 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:Received:From:To:Cc:Subject:References:X-URL:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=RBXeOyMZh6uHvcG1UinK1H576YL0iWuryenGpYgXHdCNLxXu119Nk3wO89mkHO YdnORFa6J+Vzq6KoEbAjyF0djJPrMWxwZtB+ZRedKQSG9MdAkpp69heT0l0VcF+/ jKnyTFZ5x8o7duqd1JTpt2tOAyt8lDoDwaB2GrZiqx94A=; Received: (qmail 18329 invoked by alias); 16 Feb 2013 10:08:34 -0000 Received: (qmail 18271 invoked by uid 22791); 16 Feb 2013 10:08:32 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CF X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 16 Feb 2013 10:08:24 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1GA8N1Z003615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 16 Feb 2013 05:08:23 -0500 Received: from localhost (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1GA8LRj022180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 16 Feb 2013 05:08:23 -0500 Received: by localhost (Postfix, from userid 1000) id 489664064A; Sat, 16 Feb 2013 11:08:21 +0100 (CET) From: Dodji Seketeli To: Jakub Jelinek Cc: Richard Biener , GCC Patches Subject: Re: [PATCH] Add new debug_bb_range debugging function References: <87a9r4a95w.fsf@redhat.com> <20130216095751.GW1215@tucnak.zalov.cz> X-URL: http://www.redhat.com Date: Sat, 16 Feb 2013 11:08:21 +0100 In-Reply-To: <20130216095751.GW1215@tucnak.zalov.cz> (Jakub Jelinek's message of "Sat, 16 Feb 2013 10:57:51 +0100") Message-ID: <874nhca7vu.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 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 Jakub Jelinek writes: > On Sat, Feb 16, 2013 at 10:40:43AM +0100, Dodji Seketeli wrote: >> --- a/gcc/cfg.c >> +++ b/gcc/cfg.c >> @@ -663,6 +663,21 @@ debug_bb_n (int n) >> return bb; >> } >> >> +/* Dumps cfg related information about basic blocks, from number 'S' >> + to number E, to stderr. */ >> + >> +DEBUG_FUNCTION basic_block >> +debug_bb_range (int s, int e) >> +{ >> + basic_block bb = NULL; >> + for (int i = s; i <= e; ++i) >> + { >> + bb = BASIC_BLOCK (i); >> + debug_bb (bb); > > At some points after cfg changes, but before cfg cleanup there might be > gaps, so I think you want if (bb) debug_bb (bb);, otherwise it could crash > in that case. Right. I have updated the patch below for that and also to ensure that we don't try to access a basic block with number >= last_basic_block. Thanks. gcc/ * basic-block.h (debug_bb_range): Declare ... * cfg.c (debug_bb_range): ... new function. --- gcc/basic-block.h | 1 + gcc/cfg.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/basic-block.h b/gcc/basic-block.h index 90eb57b..8407c4a 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -752,6 +752,7 @@ extern bool predictable_edge_p (edge); extern void init_flow (struct function *); extern void debug_bb (basic_block); extern basic_block debug_bb_n (int); +extern basic_block debug_bb_range (int, int); extern void dump_flow_info (FILE *, int); extern void expunge_block (basic_block); extern void link_block (basic_block, basic_block); diff --git a/gcc/cfg.c b/gcc/cfg.c index 9e4380c..d72e075 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -663,6 +663,22 @@ debug_bb_n (int n) return bb; } +/* Dumps cfg related information about basic blocks, from number 'S' + to number E, to stderr. */ + +DEBUG_FUNCTION basic_block +debug_bb_range (int s, int e) +{ + basic_block bb = NULL; + for (int i = s; i <= e && i < last_basic_block; ++i) + { + bb = BASIC_BLOCK (i); + if (bb) + debug_bb (bb); + } + return bb; +} + /* Dumps cfg related information about basic block BB to OUTF. If HEADER is true, dump things that appear before the instructions contained in BB. If FOOTER is true, dump things that appear after.