From patchwork Fri Feb 11 09:49:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 82726 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 32416B7124 for ; Fri, 11 Feb 2011 20:52:38 +1100 (EST) Received: (qmail 7942 invoked by alias); 11 Feb 2011 09:52:36 -0000 Received: (qmail 7927 invoked by uid 22791); 11 Feb 2011 09:52:35 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Feb 2011 09:52:29 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 52539CB01DB for ; Fri, 11 Feb 2011 10:52:27 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AIXYBdFhuxBi for ; Fri, 11 Feb 2011 10:52:18 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 72223CB01D7 for ; Fri, 11 Feb 2011 10:52:18 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR tree-optimization/47420 Date: Fri, 11 Feb 2011 10:49:04 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201102111049.05138.ebotcazou@adacore.com> 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 is an ICE at -O2 on i686-pc-mingw32 caused by partial inlining. We start with: : MEM[(struct sfTextCtrlBase *)this_1(D)].D.1899.D.1763._vptr.fooControlBase = &_ZTV14sfTextCtrlBase[2]; MEM[(struct sfTextCtrlBase *)this_1(D)].D.1900._vptr.sfTextAreaBase = &_ZTV14sfTextCtrlBase[6]; MEM[(struct sfTextCtrlBase *)this_1(D)].D.1901.D.1826._vptr.sfTextEntryBase = &_ZTV14sfTextCtrlBase[10]; D.2174_11 = this_1(D) + 8; MEM[(struct sfTextEntry *)this_1(D) + 8B].D.1826._vptr.sfTextEntryBase = &_ZTV11sfTextEntry[2]; sfTextEntryBase::~sfTextEntryBase (D.2174_11); [...] : MEM[(struct sfTextAreaBase *)this_1(D) + 4B]._vptr.sfTextAreaBase = &_ZTV14sfTextAreaBase[2]; : resx 5 : MEM[(struct fooControl *)this_1(D)].D.1763._vptr.fooControlBase = &_ZTV10fooControl[2]; fooControlBase::~fooControlBase (this_1(D)); : resx 4 L5/L6 is the cleanup of the L0 block. Partial inlining splits at L5: : MEM[(struct sfTextCtrlBase *)this_1(D)].D.1899.D.1763._vptr.fooControlBase = &_ZTV14sfTextCtrlBase[2]; MEM[(struct sfTextCtrlBase *)this_1(D)].D.1900._vptr.sfTextAreaBase = &_ZTV14sfTextCtrlBase[6]; MEM[(struct sfTextCtrlBase *)this_1(D)].D.1901.D.1826._vptr.sfTextEntryBase = &_ZTV14sfTextCtrlBase[10]; D.2174_11 = this_1(D) + 8; MEM[(struct sfTextEntry *)this_1(D) + 8B].D.1826._vptr.sfTextEntryBase = &_ZTV11sfTextEntry[2]; sfTextEntryBase::~sfTextEntryBase (D.2174_11); [...] : sfTextCtrl::sfTextCtrl (this_1(D)); with the split up part: sfTextCtrl::sfTextCtrl() (struct sfTextCtrl * const this) { struct sfTextCtrlBase * D.2188; struct sfTextEntry * D.2187; void * parent; : : MEM[(struct sfTextAreaBase *)this_1(D) + 4B]._vptr.sfTextAreaBase = &_ZTV14sfTextAreaBase[2]; Invalid sum of outgoing probabilities 0.0% : resx 3 : MEM[(struct fooControl *)this_1(D)].D.1763._vptr.fooControlBase = &_ZTV10fooControl[2]; fooControlBase::~fooControlBase (this_1(D)); : resx 2 } Then the split up part is inlined back into the original function: : MEM[(struct sfTextCtrlBase *)D.2028_1].D.1899.D.1763._vptr.fooControlBase = &_ZTV14sfTextCtrlBase[2]; MEM[(struct sfTextCtrlBase *)D.2028_1].D.1900._vptr.sfTextAreaBase = &_ZTV14sfTextCtrlBase[6]; MEM[(struct sfTextCtrlBase *)D.2028_1].D.1901.D.1826._vptr.sfTextEntryBase = &_ZTV14sfTextCtrlBase[10]; D.2245_8 = D.2028_1 + 8; MEM[(struct sfTextEntry *)D.2028_1 + 8B].D.1826._vptr.sfTextEntryBase = &_ZTV11sfTextEntry[2]; sfTextEntryBase::~sfTextEntryBase (D.2245_8); [...] : MEM[(struct sfTextAreaBase *)D.2028_1 + 4B]._vptr.sfTextAreaBase = &_ZTV14sfTextAreaBase[2]; Invalid sum of outgoing probabilities 0.0% : resx 12 : MEM[(struct fooControl *)D.2028_1].D.1763._vptr.fooControlBase = &_ZTV10fooControl[2]; fooControlBase::~fooControlBase (D.2028_1); : resx 11 The problem is that the new EH regions created by inlining (11 and 12) aren't connected with the landing pads; the landing pad of the throwing statement: sfTextEntryBase::~sfTextEntryBase (D.2245_8); is still connected to the original region 5. So remove_unreachable_handlers computes that region 12 is unreachable and turns resx 12 into a trap, which is caught by an assertion because the successor L10 isn't reachable any more. Partial inlining already punts on external RESXs: /* FIXME: We can split regions containing EH. We can not however split RESX, EH_DISPATCH and EH_POINTER referring to same region into different partitions. This would require tracking of EH regions and checking in consider_split_point if they are not used elsewhere. */ if (gimple_code (stmt) == GIMPLE_RESX && stmt_can_throw_external (stmt)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Cannot split: external resx.\n"); can_split = false; } but it seems to me that the "external" is bogus here, hence the proposed fix. Tested on i586-suse-linux, OK for the mainline? 2011-02-11 Eric Botcazou PR tree-optimization/47420 * ipa-split.c (visit_bb): Put on any kind of GIMPLE_RESX. 2011-02-11 Eric Botcazou * g++.dg/opt/inline17.C: New test. Index: ipa-split.c =================================================================== --- ipa-split.c (revision 169914) +++ ipa-split.c (working copy) @@ -643,11 +643,10 @@ visit_bb (basic_block bb, basic_block re into different partitions. This would require tracking of EH regions and checking in consider_split_point if they are not used elsewhere. */ - if (gimple_code (stmt) == GIMPLE_RESX - && stmt_can_throw_external (stmt)) + if (gimple_code (stmt) == GIMPLE_RESX) { if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Cannot split: external resx.\n"); + fprintf (dump_file, "Cannot split: resx.\n"); can_split = false; } if (gimple_code (stmt) == GIMPLE_EH_DISPATCH)