From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24980 invoked by alias); 12 Oct 2015 13:11:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 24960 invoked by uid 89); 12 Oct 2015 13:11:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 Oct 2015 13:11:34 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51653) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zlct1-0003vn-S3 for gcc-patches@gnu.org; Mon, 12 Oct 2015 09:11:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlcsv-0006wd-Kr for gcc-patches@gnu.org; Mon, 12 Oct 2015 09:11:31 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:46581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlcsv-0006wD-Ew for gcc-patches@gnu.org; Mon, 12 Oct 2015 09:11:25 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zlcst-0003nc-KB from Tom_deVries@mentor.com for gcc-patches@gnu.org; Mon, 12 Oct 2015 06:11:23 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 12 Oct 2015 14:11:22 +0100 To: "gcc-patches@gnu.org" From: Tom de Vries Subject: [PATCH] Check no unreachable blocks in inverted_post_order_compute Message-ID: <561BB14D.9080309@mentor.com> Date: Mon, 12 Oct 2015 13:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090100000204090305040409" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-10/txt/msg01129.txt.bz2 --------------090100000204090305040409 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 383 Hi, in the header comment of function inverted_post_order_compute in cfganal.c we find: ... This function assumes that all blocks in the CFG are reachable from the ENTRY (but not necessarily from EXIT). ... This patch checks that there are indeed no unreachable blocks when calling inverted_post_order_compute. OK for trunk if bootstrap/regtest succeeds? Thanks, - Tom --------------090100000204090305040409 Content-Type: text/x-patch; name="0001-Check-no-unreachable-blocks-in-inverted_post_order_c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-Check-no-unreachable-blocks-in-inverted_post_order_c.pa"; filename*1="tch" Content-length: 1736 Check no unreachable blocks in inverted_post_order_compute 2015-10-12 Tom de Vries * cfganal.c (verify_no_unreachable_blocks): New function. (inverted_post_order_compute) [ENABLE_CHECKING]: Call verify_no_unreachable_blocks. cfganal.h (verify_no_unreachable_blocks): Declare. --- gcc/cfganal.c | 17 +++++++++++++++++ gcc/cfganal.h | 1 + 2 files changed, 18 insertions(+) diff --git a/gcc/cfganal.c b/gcc/cfganal.c index 279c3b5..1f935eb 100644 --- a/gcc/cfganal.c +++ b/gcc/cfganal.c @@ -193,6 +193,19 @@ find_unreachable_blocks (void) free (worklist); } + +/* Verify that there are no unreachable blocks in the current function. */ + +void +verify_no_unreachable_blocks (void) +{ + find_unreachable_blocks (); + + basic_block bb; + FOR_EACH_BB_FN (bb, cfun) + gcc_assert ((bb->flags & BB_REACHABLE) != 0); +} + /* Functions to access an edge list with a vector representation. Enough data is kept such that given an index number, the @@ -772,6 +785,10 @@ inverted_post_order_compute (int *post_order) int post_order_num = 0; sbitmap visited; +#if ENABLE_CHECKING + verify_no_unreachable_blocks (); +#endif + /* Allocate stack for back-tracking up CFG. */ stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1); sp = 0; diff --git a/gcc/cfganal.h b/gcc/cfganal.h index 3eb4764..2ad00c0 100644 --- a/gcc/cfganal.h +++ b/gcc/cfganal.h @@ -49,6 +49,7 @@ private: extern bool mark_dfs_back_edges (void); extern void find_unreachable_blocks (void); +extern void verify_no_unreachable_blocks (void); struct edge_list * create_edge_list (void); void free_edge_list (struct edge_list *); void print_edge_list (FILE *, struct edge_list *); -- 1.9.1 --------------090100000204090305040409--