From patchwork Wed Sep 10 17:42:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 387911 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B751F1400A0 for ; Thu, 11 Sep 2014 03:43:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=Bb+eQBZMp0fyI4lQxvIWUai7XwyJ7gENhOTS0D2P9Bq jA+rrMo7Ue/kPZ1x19/FHl2GTJPflEYln4RIc2RzilmoIAlOESgwZbmc6auO6UKm 1UFVh8wG4N3V4OqGg3GqCax2X0qHBmIz9tw2Uw25rAW+6pUSzViMigpWu2NMSFWY = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=Kww+BcwqkVIMIeEqzgvD+guUKSw=; b=vfDOsG/itjwCnbANi 7I9E8hBHexiQTqYSzTsN/JhEz2xgOkaFfmXZ8go9xLmRZI7RH8hQx4wAJOOPRsCo wI281lVAspF3leqlOupY96sSw/LnS0haJ+s+guF8Q/q/4144B0NkI65gWgdq67Q+ NIcM2XXkx6UbUSkXh4znyHtsGw= Received: (qmail 29156 invoked by alias); 10 Sep 2014 17:43:06 -0000 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 Received: (qmail 29144 invoked by uid 89); 10 Sep 2014 17:43:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 10 Sep 2014 17:43:04 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8AHh3bb021450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Sep 2014 13:43:03 -0400 Received: from [10.10.116.27] ([10.10.116.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8AHh2Vj002217; Wed, 10 Sep 2014 13:43:03 -0400 Message-ID: <54108DA3.9060806@redhat.com> Date: Wed, 10 Sep 2014 13:42:59 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: Jan Hubicka CC: gcc-patches List Subject: RFA: PATCH to ipa-devirt for c++/58678 The failure with -flto is due to make_decl_local clearing DECL_COMDAT, so the check in ipa_devirt allows devirtualization to an implicitly declared destructor. It's not clear to me why make_decl_local needs to clear DECL_COMDAT, but it's simpler to just remove that check from ipa_devirt. Tested x86_64-pc-linux-gnu. OK for trunk and 4.9? commit f88473ffec00cd8b537f7d92102f99fbd855b685 Author: Jason Merrill Date: Fri Aug 29 12:44:54 2014 -0400 PR c++/58678 * ipa-devirt.c (ipa_devirt): Don't check DECL_COMDAT. diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index f98a18e..948ae23 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -3952,8 +3952,7 @@ ipa_devirt (void) /* Don't use an implicitly-declared destructor (c++/58678). */ struct cgraph_node *non_thunk_target = likely_target->function_symbol (); - if (DECL_ARTIFICIAL (non_thunk_target->decl) - && DECL_COMDAT (non_thunk_target->decl)) + if (DECL_ARTIFICIAL (non_thunk_target->decl)) { if (dump_file) fprintf (dump_file, "Target is artificial\n\n"); diff --git a/gcc/testsuite/g++.dg/ipa/devirt-28a.C b/gcc/testsuite/g++.dg/ipa/devirt-28a.C new file mode 100644 index 0000000..bdd1682 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-28a.C @@ -0,0 +1,15 @@ +// PR c++/58678 +// { dg-options "-O3 -flto -shared -fPIC -Wl,--no-undefined" } +// { dg-do link { target { gld && fpic } } } + +struct A { + virtual ~A(); +}; +struct B : A { + virtual int m_fn1(); +}; +void fn1(B* b) { + delete b; +} + +int main() {}