From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17975 invoked by alias); 4 Oct 2004 14:46:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17907 invoked from network); 4 Oct 2004 14:46:25 -0000 Received: from unknown (HELO physunc.phy.uc.edu) (129.137.4.6) by sourceware.org with SMTP; 4 Oct 2004 14:46:25 -0000 Received: from bethe.phy.uc.edu (bethe.geop.uc.edu [10.44.6.245]) by physunc.phy.uc.edu (8.9.3p2/8.9.3) with ESMTP id KAA25141 for ; Mon, 4 Oct 2004 10:46:23 -0400 (EDT) Received: from [10.44.106.140] (zhivago.geop.uc.edu [10.44.106.140]) by bethe.phy.uc.edu (8.9.3p2/8.9.3) with ESMTP id KAA09700 for ; Mon, 4 Oct 2004 10:46:24 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v618) Content-Transfer-Encoding: 7bit Message-Id: <2852718A-1614-11D9-81C0-000A95D692F4@physics.uc.edu> Content-Type: text/plain; charset=US-ASCII; format=flowed To: GCC Patches From: Andrew Pinski Subject: [PATCH] Fix PRs middle-end/15014 and middle-end/16973, removing labels with their address taken Date: Mon, 04 Oct 2004 15:06:00 -0000 X-SW-Source: 2004-10/txt/msg00247.txt.bz2 The problem here is that we were getting rid of some bb as they were being marked as unreachable (which is true in the code flow sense) but should not be removed. I fixed this by adding an edge from the first bb to the label's bb which has its address taken. I think this is most correct solution as this does not happen much we should not have to worry about losing some optimization possibility from doing it this way. OK? Bootstrapped and tested on powerpc-apple-darwin. Thanks, Andrew Pinski Testcase: void f (void) { static __SIZE_TYPE__ u = &&a-&&b; a : b : return; } ChangeLog: * tre-cfg.c (make_edges): After making the edges but before cleaning up the cfg, make an edge from the first BB to ever BB which we take the address of the label. Patch: Index: tree-cfg.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v retrieving revision 2.64 diff -u -p -r2.64 tree-cfg.c --- tree-cfg.c 2 Oct 2004 12:47:10 -0000 2.64 +++ tree-cfg.c 4 Oct 2004 14:44:19 -0000 @@ -417,6 +417,7 @@ static void make_edges (void) { basic_block bb; + basic_block target_bb; /* Create an edge from entry to the first block with executable statements in it. */ @@ -448,6 +449,30 @@ make_edges (void) /* We do not care about fake edges, so remove any that the CFG builder inserted for completeness. */ remove_fake_exit_edges (); + + /* Look for the block starting with the destination label. In the + case of a computed label, make an edge from the entry block to the + computed lablel. */ + FOR_EACH_BB (target_bb) + { + block_stmt_iterator bsi; + + for (bsi = bsi_start (target_bb); !bsi_end_p (bsi); bsi_next (&bsi)) + { + tree target = bsi_stmt (bsi); + + if (TREE_CODE (target) != LABEL_EXPR) + break; + + if (FORCED_LABEL (LABEL_EXPR_LABEL (target)) + || DECL_NONLOCAL (LABEL_EXPR_LABEL (target))) + { + make_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest, + target_bb, EDGE_ABNORMAL); + break; + } + } + } /* Clean up the graph and warn for unreachable code. */ cleanup_tree_cfg ();