From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3358 invoked by alias); 29 Jun 2010 18:54:02 -0000 Received: (qmail 3274 invoked by uid 22791); 29 Jun 2010 18:54:01 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_FN,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, 29 Jun 2010 18:53:54 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5TIrqAv029852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Jun 2010 14:53:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5TIrpwF031796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 29 Jun 2010 14:53:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5TIskk1012564; Tue, 29 Jun 2010 20:54:46 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5TIskTA012563; Tue, 29 Jun 2010 20:54:46 +0200 Date: Tue, 29 Jun 2010 19:25:00 -0000 From: Jakub Jelinek To: Richard Guenther , Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801) Message-ID: <20100629185445.GQ25077@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg03037.txt.bz2 Hi! When a fndecl is DECL_ONE_ONLY and has DECL_SECTION_NAME already set (e.g. because of emitting associated thunks), its virtual clones which are not DECL_ONE_ONLY definitely must not reuse its section, because that results in section conflicts. For non-comdat functions e.g. put by user into some special section I think we can just reuse that section. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-06-29 Jakub Jelinek PR tree-optimization/43801 * cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME if old_decl was DECL_ONE_ONLY. * g++.dg/torture/pr43801.C: New test. --- gcc/cgraph.c.jj 2010-06-28 15:36:30.000000000 +0200 +++ gcc/cgraph.c 2010-06-29 18:05:36.000000000 +0200 @@ -2217,6 +2217,8 @@ cgraph_create_virtual_clone (struct cgra ??? We cannot use COMDAT linkage because there is no ABI support for this. */ DECL_EXTERNAL (new_node->decl) = 0; + if (DECL_ONE_ONLY (old_decl)) + DECL_SECTION_NAME (new_node->decl) = NULL; DECL_COMDAT_GROUP (new_node->decl) = 0; TREE_PUBLIC (new_node->decl) = 0; DECL_COMDAT (new_node->decl) = 0; --- gcc/testsuite/g++.dg/torture/pr43801.C.jj 2010-06-29 18:09:32.000000000 +0200 +++ gcc/testsuite/g++.dg/torture/pr43801.C 2010-06-29 18:10:34.000000000 +0200 @@ -0,0 +1,22 @@ +// PR tree-optimization/43801 +// { dg-do compile } +// { dg-options "-fipa-cp -fipa-cp-clone" } + +struct A +{ + virtual void f (int); +}; +struct B : virtual A +{ + virtual void f (int i) { if (i) A::f(0); } +}; +struct C : virtual B +{ + virtual void f (int) { B::f(0); } +}; + +void +foo () +{ + C (); +} Jakub