From patchwork Tue Jan 18 23:18:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 79375 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 68095B713B for ; Wed, 19 Jan 2011 10:18:53 +1100 (EST) Received: (qmail 8623 invoked by alias); 18 Jan 2011 23:18:52 -0000 Received: (qmail 8614 invoked by uid 22791); 18 Jan 2011 23:18:51 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD 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; Tue, 18 Jan 2011 23:18:46 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0INIj9s026474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jan 2011 18:18:45 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0INIhVf024661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 18 Jan 2011 18:18:44 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0INIhSr029653; Wed, 19 Jan 2011 00:18:43 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0INIhmC029652; Wed, 19 Jan 2011 00:18:43 +0100 Date: Wed, 19 Jan 2011 00:18:43 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Richard Henderson Subject: [committed] Fix endless moving of landing pads in ehcleanup (PR tree-optimization/47290) Message-ID: <20110118231842.GM2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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! This patch fixes endless moving of landing pads across empty bbs with single successor if the landing pad is followed by empty infinite loop. Approved by Richard in bugzilla, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2011-01-19 Jakub Jelinek PR tree-optimization/47290 * tree-eh.c (infinite_empty_loop_p): New function. (cleanup_empty_eh): Use it. * g++.dg/torture/pr47290.C: New test. Jakub --- gcc/tree-eh.c.jj 2010-11-19 20:56:55.000000000 +0100 +++ gcc/tree-eh.c 2011-01-18 18:16:11.000000000 +0100 @@ -1,5 +1,5 @@ /* Exception handling semantics and decomposition for trees. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -3724,6 +3724,42 @@ cleanup_empty_eh_unsplit (basic_block bb return false; } +/* Return true if edge E_FIRST is part of an empty infinite loop + or leads to such a loop through a series of single successor + empty bbs. */ + +static bool +infinite_empty_loop_p (edge e_first) +{ + bool inf_loop = false; + edge e; + + if (e_first->dest == e_first->src) + return true; + + e_first->src->aux = (void *) 1; + for (e = e_first; single_succ_p (e->dest); e = single_succ_edge (e->dest)) + { + gimple_stmt_iterator gsi; + if (e->dest->aux) + { + inf_loop = true; + break; + } + e->dest->aux = (void *) 1; + gsi = gsi_after_labels (e->dest); + if (!gsi_end_p (gsi) && is_gimple_debug (gsi_stmt (gsi))) + gsi_next_nondebug (&gsi); + if (!gsi_end_p (gsi)) + break; + } + e_first->src->aux = NULL; + for (e = e_first; e->dest->aux; e = single_succ_edge (e->dest)) + e->dest->aux = NULL; + + return inf_loop; +} + /* Examine the block associated with LP to determine if it's an empty handler for its EH region. If so, attempt to redirect EH edges to an outer region. Return true the CFG was updated in any way. This @@ -3763,7 +3799,7 @@ cleanup_empty_eh (eh_landing_pad lp) if (gsi_end_p (gsi)) { /* For the degenerate case of an infinite loop bail out. */ - if (e_out->dest == bb) + if (infinite_empty_loop_p (e_out)) return false; return cleanup_empty_eh_unsplit (bb, e_out, lp); --- gcc/testsuite/g++.dg/torture/pr47290.C.jj 2011-01-18 18:10:09.000000000 +0100 +++ gcc/testsuite/g++.dg/torture/pr47290.C 2011-01-18 18:10:09.000000000 +0100 @@ -0,0 +1,19 @@ +// PR tree-optimization/47290 +// { dg-do compile } + +struct V +{ + V (int = 0); + ~V () + { + for (;;) + ; + } + int size (); +}; + +struct S +{ + V a, b; + S () : b (a.size ()) {} +} s;