From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11896 invoked by alias); 10 Oct 2004 14:57:12 -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 11885 invoked from network); 10 Oct 2004 14:57:10 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 10 Oct 2004 14:57:10 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i9AEv7o7015674; Sun, 10 Oct 2004 10:57:07 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9AEv6r22958; Sun, 10 Oct 2004 10:57:06 -0400 Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with ESMTP id i9AEukHr030420; Sun, 10 Oct 2004 10:56:46 -0400 Received: (from jakub@localhost) by devserv.devel.redhat.com (8.12.11/8.12.11/Submit) id i9AEukvI030412; Sun, 10 Oct 2004 10:56:46 -0400 Date: Sun, 10 Oct 2004 15:20:00 -0000 From: Jakub Jelinek To: Zdenek Dvorak Cc: dnovillo@redhat.com, rth@redhat.com, gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR tree-optimization/17724 (take 2) Message-ID: <20041010145645.GZ31909@devserv.devel.redhat.com> Reply-To: Jakub Jelinek References: <20041009082440.GB22455@atrey.karlin.mff.cuni.cz> <20041009090000.GA24787@atrey.karlin.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041009090000.GA24787@atrey.karlin.mff.cuni.cz> User-Agent: Mutt/1.4.1i X-SW-Source: 2004-10/txt/msg00854.txt.bz2 On Sat, Oct 09, 2004 at 11:00:00AM +0200, Zdenek Dvorak wrote: > this does not seem to be the right fix to me: > > 1) Change to delete_unreachable_blocks is not necessary. As long as > dominators are set correctly before delete_unreachable_blocks, > they are also set correctly after it (since removal of unreachable > blocks cannot affect any path from entry to basic block bb, and > immediate dominator is determined from exactly these paths). Are you sure that in all other cases where some basic blocks become unreachable code that removes the edge ensures that dominators are freed or recomputed for all basic blocks where idom(bb) could change? I have tested following patch and it certainly cures the problem (bootstrapped/regtested on 7 arches). 2004-10-09 Jakub Jelinek Zdenek Dvorak PR tree-optimization/17724 * tree-cfg.c (tree_purge_dead_eh_edges): Free dominance info. * g++.dg/opt/pr17724-1.C: New test. * g++.dg/opt/pr17724-2.C: New test. * g++.dg/opt/pr17724-3.C: New test. * g++.dg/opt/pr17724-4.C: New test. * g++.dg/opt/pr17724-5.C: New test. * g++.dg/opt/pr17724-6.C: New test. --- gcc/tree-cfg.c.jj 2004-10-02 04:46:07.000000000 -0400 +++ gcc/tree-cfg.c 2004-10-09 13:24:42.000000000 -0400 @@ -5016,6 +5016,26 @@ tree_purge_dead_eh_edges (basic_block bb ei_next (&ei); } + /* Removal of dead EH edges might change dominators of not + just immediate successors. E.g. when bb1 is changed so that + it no longer can throw and bb1->bb3 and bb1->bb4 are dead + eh edges purged by this function in: + 0 + / \ + v v + 1-->2 + / \ | + v v | + 3-->4 | + \ v + --->5 + | + - + idom(bb5) must be recomputed. For now just free the dominance + info. */ + if (changed) + free_dominance_info (CDI_DOMINATORS); + return changed; } --- gcc/testsuite/g++.dg/opt/pr17724-4.C.jj 2004-10-02 11:27:29.000000000 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-4.C 2004-10-02 11:29:21.803990546 +0200 @@ -0,0 +1,24 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +extern "C" char *strcpy (char* d, const char* s); + +class A { public: A (); ~A (); }; + +inline char * B (char *s, const char *t) +{ return ::strcpy (s, t); } + +class C { int D (void); int E; }; + +int C::D (void) +{ + A a; + try + { + char z[22]; + if (this->E) B (z, ""); + return 0; + } + catch (int &f) { return -1; } +} --- gcc/testsuite/g++.dg/opt/pr17724-6.C.jj 2004-10-02 11:27:29.000000000 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-6.C 2004-10-02 11:28:39.000000000 +0200 @@ -0,0 +1,24 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +extern char *strcpy (char* d, const char* s); + +class A { public: A (); ~A (); }; + +inline char * B (char *s, const char *t) +{ return ::strcpy (s, t); } + +class C { int D (void); int E; }; + +int C::D (void) +{ + A a; + try + { + char z[22]; + if (this->E) B (z, ""); + return 0; + } + catch (int &f) { return -1; } +} --- gcc/testsuite/g++.dg/opt/pr17724-1.C.jj 2004-10-02 11:13:45.797278812 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-1.C 2004-10-02 11:13:45.797278812 +0200 @@ -0,0 +1,23 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +namespace N { char *strcpy (char *, const char *); } +extern "C" char *strcpy (char *, const char *) throw (); +inline char *N::strcpy (char *s, const char *t) { return ::strcpy (s, t); } + +struct S { ~S (); }; +int foo (); + +int +main () +{ + S s; + int a; + char b[64]; + N::strcpy (b, "ABCDEFGHIJKLM"); + while ((a = foo ()) != -1) + if (a) + return -1; + return 0; +} --- gcc/testsuite/g++.dg/opt/pr17724-2.C.jj 2004-10-02 11:13:45.797278812 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-2.C 2004-10-02 11:13:45.797278812 +0200 @@ -0,0 +1,23 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +namespace N { char *strcpy (char *, const char *); } +extern "C" char *strcpy (char *, const char *); +inline char *N::strcpy (char *s, const char *t) { return ::strcpy (s, t); } + +struct S { ~S (); }; +int foo (); + +int +main () +{ + S s; + int a; + char b[64]; + N::strcpy (b, "ABCDEFGHIJKLM"); + while ((a = foo ()) != -1) + if (a) + return -1; + return 0; +} --- gcc/testsuite/g++.dg/opt/pr17724-3.C.jj 2004-10-02 11:27:29.650919752 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-3.C 2004-10-02 11:29:13.933389195 +0200 @@ -0,0 +1,24 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +extern "C" char *strcpy (char* d, const char* s) throw (); + +class A { public: A (); ~A (); }; + +inline char * B (char *s, const char *t) +{ return ::strcpy (s, t); } + +class C { int D (void); int E; }; + +int C::D (void) +{ + A a; + try + { + char z[22]; + if (this->E) B (z, ""); + return 0; + } + catch (int &f) { return -1; } +} --- gcc/testsuite/g++.dg/opt/pr17724-5.C.jj 2004-10-02 11:27:29.000000000 +0200 +++ gcc/testsuite/g++.dg/opt/pr17724-5.C 2004-10-02 11:29:29.275662780 +0200 @@ -0,0 +1,24 @@ +// PR tree-optimization/17724 +// { dg-do compile } +// { dg-options "-O2" } + +extern char *strcpy (char* d, const char* s) throw (); + +class A { public: A (); ~A (); }; + +inline char * B (char *s, const char *t) +{ return ::strcpy (s, t); } + +class C { int D (void); int E; }; + +int C::D (void) +{ + A a; + try + { + char z[22]; + if (this->E) B (z, ""); + return 0; + } + catch (int &f) { return -1; } +} Jakub