From patchwork Wed Jan 25 16:04:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 137793 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 491A0B6F67 for ; Thu, 26 Jan 2012 03:04:24 +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=1328112265; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:In-Reply-To:Message-ID:References:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=CInJbL0 x3yEbflkZFaZKuSSrR8s=; b=kScOV7nagzYGLSx5wKk1o+acFCZJoSiYDpPYUNy YyXIgv3Ys9V/fAzp0gVVlkVnB/wKPtACB4PkgEWqJqkwBPL8UfCkh33cafSQu5Hf D3S4BU0EQrfs3RpjR7tQniDiHj4ZYrZXM8rcbmQf/pLaeDvvCO1O1OOC2YoG2vny ynAA= 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:Date:From:To:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=OruwaoVJCSlVeWcvxuHnkbQ/tDJCpKfVsi96OnZWFQxLVMPT7s9SE2LtT4pn7h BVNvuH6z4nNkKTZ+p5GnNMrrtNZA98vL/kuOsGYX0/Qk0Ydudp2y5jqmq4voVbGD HssKjDr29AJKRvgt4WPzINpbKhH09XTyp2psAeUYP5hxs=; Received: (qmail 6858 invoked by alias); 25 Jan 2012 16:04:19 -0000 Received: (qmail 6844 invoked by uid 22791); 25 Jan 2012 16:04:18 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Jan 2012 16:04:04 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id BF44390B1D for ; Wed, 25 Jan 2012 17:04:03 +0100 (CET) Date: Wed, 25 Jan 2012 17:04:03 +0100 (CET) From: Michael Matz To: gcc-patches@gcc.gnu.org Subject: Re: Fix PR48794 some more In-Reply-To: Message-ID: References: MIME-Version: 1.0 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, On Wed, 25 Jan 2012, Michael Matz wrote: > so, the below adjusted testcase from PR48794 still fails for the same > reasons (regions still referenced from RESX being removed). I was split > minds about if that's a new bug or just an extension of the old bug, so > I hijacked the old PR. In any case, remove_unreachable_handlers_no_lp > needs similar handling like remove_unreachable_handlers. > > Patch fixes the segfault and is currently in regstrapping on x86_64-linux. > Okay for trunk? Actually, resx/eh_dispatch always are the last BB statements, so the loop doesn't need to look at all statements in a BB, making it quite somewhat faster. Consider the tree-eh.c to be looking like so: Ciao, Michael. Index: tree-eh.c =================================================================== --- tree-eh.c (revision 183524) +++ tree-eh.c (working copy) @@ -3617,14 +3617,40 @@ remove_unreachable_handlers_no_lp (void) { eh_region r; int i; + sbitmap r_reachable; + basic_block bb; + + r_reachable = sbitmap_alloc (VEC_length (eh_region, cfun->eh->region_array)); + sbitmap_zero (r_reachable); + + FOR_EACH_BB (bb) + { + gimple stmt = last_stmt (bb); + if (stmt) + /* Avoid removing regions referenced from RESX/EH_DISPATCH. */ + switch (gimple_code (stmt)) + { + case GIMPLE_RESX: + SET_BIT (r_reachable, gimple_resx_region (stmt)); + break; + case GIMPLE_EH_DISPATCH: + SET_BIT (r_reachable, gimple_eh_dispatch_region (stmt)); + break; + default: + break; + } + } for (i = 1; VEC_iterate (eh_region, cfun->eh->region_array, i, r); ++i) - if (r && r->landing_pads == NULL && r->type != ERT_MUST_NOT_THROW) + if (r && r->landing_pads == NULL && r->type != ERT_MUST_NOT_THROW + && !TEST_BIT (r_reachable, i)) { if (dump_file) fprintf (dump_file, "Removing unreachable region %d\n", i); remove_eh_handler (r); } + + sbitmap_free (r_reachable); } /* Undo critical edge splitting on an EH landing pad. Earlier, we