From patchwork Thu May 15 14:45:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 349259 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 87BB4140076 for ; Fri, 16 May 2014 00:45:23 +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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=YZBdAs5pR4lcGts0S1ggMMZCQt0IqxpzbQIqr3h4cdSZbpMRqp JA+pOazz2F5PDWLx6Do+zCfpzsFS3+8UkjlZ/IKEz+PfHKP+BGYN0x3TgRW0LD4R MDKumGOIfYIcWPaes3JCIFDQUfJovuMwei8uvFn3SRid2nrIeL37CK1IY= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=8qn0sgQKxdeFfwUKM2q7qmRZjMU=; b=XR+nC9xhNRAHpf/OfoF2 CTZduf8KoJhafPH7wMJg/vN3Dr/mu5JwLK1Yldl1YmsbK+Gmbjd2hdBwEriRVr2m jhSDln+J8khmGRY5FxGbxBPMbkDoYubePbu0rHLJV0Xx1G1fwyiiHWVecK+8iG+6 dkTYg1vR7a07Sq/ZGGaE7HM= Received: (qmail 8840 invoked by alias); 15 May 2014 14:45:16 -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 8821 invoked by uid 89); 15 May 2014 14:45:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 15 May 2014 14:45:15 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5C832AC3C; Thu, 15 May 2014 14:45:12 +0000 (UTC) Date: Thu, 15 May 2014 16:45:11 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 61085] Add missing type_preserved check Message-ID: <20140515144511.GJ30762@virgil.suse> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, PR 61085 revealed that I forgot to put a type_preserved check to an important spot, namely to update_indirect_edges_after_inlining, which leads to wrong devirtualization because the function does not ignore jump functions it should. Fixed thusly, bootstrapped and tested on x86_64-linux on both trunk and the 4.9 branch. OK for both? Thanks, Martin 2014-05-15 Martin Jambor PR ipa/61085 * ipa-prop.c (update_indirect_edges_after_inlining): Check type_preserved flag when the indirect edge is polymorphic. testsuite/ * g++.dg/ipa/pr61085.C: New test. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index da6ffe8..4f983a6 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -2877,16 +2877,20 @@ update_indirect_edges_after_inlining (struct cgraph_edge *cs, else if (jfunc->type == IPA_JF_PASS_THROUGH && ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR) { - if (ici->agg_contents - && !ipa_get_jf_pass_through_agg_preserved (jfunc)) + if ((ici->agg_contents + && !ipa_get_jf_pass_through_agg_preserved (jfunc)) + || (ici->polymorphic + && !ipa_get_jf_pass_through_type_preserved (jfunc))) ici->param_index = -1; else ici->param_index = ipa_get_jf_pass_through_formal_id (jfunc); } else if (jfunc->type == IPA_JF_ANCESTOR) { - if (ici->agg_contents - && !ipa_get_jf_ancestor_agg_preserved (jfunc)) + if ((ici->agg_contents + && !ipa_get_jf_ancestor_agg_preserved (jfunc)) + || (ici->polymorphic + && !ipa_get_jf_ancestor_type_preserved (jfunc))) ici->param_index = -1; else { diff --git a/gcc/testsuite/g++.dg/ipa/pr61085.C b/gcc/testsuite/g++.dg/ipa/pr61085.C new file mode 100644 index 0000000..531f59d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr61085.C @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-early-inlining" } */ + +struct A {}; +struct B : virtual A { + unsigned m_i; + B() : m_i () {} + virtual A *m_virt () + { + return 0; + } + ~B () + { + m_foo (); + while (m_i) + ; + } + void m_foo () + { + m_virt (); + } +}; + +class C : B { + A *m_virt () { + __builtin_abort (); + } +}; + +int main () +{ + C c; +}