From patchwork Thu Sep 12 11:49:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 274532 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 55A702C0137 for ; Thu, 12 Sep 2013 21:50:00 +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=a8eJDkUvEr/OC7iKsyNKZp2oEGkRUScpH3ldE7t+Uty24yaX93 8NoSA7IdNQui9d63Obs2VWLb9SSfDrips4iJ4qDTcI4Tf/fwPhHrnmGOZciu5vC4 M7Jd73J+L045OlWX2wEV8E6yCwmDj1rvn0vWQ9ljsjzYBUwSjca/u2uGs= 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=LlRdKDy57WfE/OKsDm+TtQ+1s8w=; b=TA0eGGaUFbnGKPTPfASN 4uTW3zQ3RbXQ6VySmKmtTlmuCbzzNJLJ9h72eDMLoEA92U+M/IeSmMpayHxSQP5O Tj8nHDihjrcpX6Gow+Wks8biSdOjuf3SunnCHlN8ziHGNhfNxQsQmWHDbClldWlt jsyximGIRk6QIEcPPY2mnGU= Received: (qmail 28048 invoked by alias); 12 Sep 2013 11:49:54 -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 28038 invoked by uid 89); 12 Sep 2013 11:49:53 -0000 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Sep 2013 11:49:53 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RDNS_NONE autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 24E3DA398F; Thu, 12 Sep 2013 13:49:51 +0200 (CEST) Date: Thu, 12 Sep 2013 13:49:50 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 58389] Do not attempt to use reference descriptions associated with removed edges Message-ID: <20130912114950.GH6732@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 58389 is another case where the reference removal code, which is now also called from the edge removal hook, ICEs when inlined edges are not removed in topological order, which ins not the case when we are removing unreachable nodes. I'd like to fix it by the patch below. When removing an edge which has a reference descriptor pointing back to it, we set that pointer to NULL and check for non-NULLness when we want to use it. Reference descriptors die only when their allocation pool does so that pointer is never stale. Bootstrapped and tested on x86_64-linux, OK for trunk? Thanks, Martin 2013-09-11 Martin Jambor PR ipa/58389 * ipa-prop.c (remove_described_reference): Give up if the edge in the reference descriptor is NULL. (ipa_edge_removal_hook): If owning a reference descriptor, set its edge to NULL. testsuite/ * g++.dg/pr58389.C: New test. Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -2506,6 +2506,8 @@ remove_described_reference (symtab_node struct cgraph_edge *origin; origin = rdesc->cs; + if (!origin) + return false; to_del = ipa_find_reference ((symtab_node) origin->caller, symbol, origin->call_stmt, origin->lto_stmt_uid); if (!to_del) @@ -3019,7 +3021,14 @@ ipa_edge_removal_hook (struct cgraph_edg struct ipa_jump_func *jf; int i; FOR_EACH_VEC_ELT (*args->jump_functions, i, jf) - try_decrement_rdesc_refcount (jf); + { + struct ipa_cst_ref_desc *rdesc; + try_decrement_rdesc_refcount (jf); + if (jf->type == IPA_JF_CONST + && (rdesc = ipa_get_jf_constant_rdesc (jf)) + && rdesc->cs == cs) + rdesc->cs = NULL; + } } ipa_free_edge_args_substructures (IPA_EDGE_REF (cs)); Index: src/gcc/testsuite/g++.dg/pr58389.C =================================================================== --- /dev/null +++ src/gcc/testsuite/g++.dg/pr58389.C @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +template +void __insertion_sort(_RandomAccessIterator, _Compare); +template +void __final_insertion_sort(_RandomAccessIterator p1, _Compare p2) { + _RandomAccessIterator a; + if (p1 - a) + ; + else + std: + __insertion_sort(0, p2); +} +template +void __introsort_loop(_RandomAccessIterator, _Size, _Compare); +template +void sort(_RandomAccessIterator, _RandomAccessIterator p2, _Compare p3) { +std: + __introsort_loop(0, 0, p3); + __final_insertion_sort(p2, p3); +} +class A { +public: + int m_fn1(); + void __lg(); + class B { + public: + int i; + int operator-(B); + }; +}; +class C; +class D { +public: + C *operator->(); +}; +class F { + A m_fn1() const; + D d_ptr; +}; +class C { + friend F; + void m_fn1(); + A children; +}; +void qt_notclosestLeaf(); +inline void C::m_fn1() { + A::B b, c; + if (children.m_fn1()) { + sort(c, b, qt_notclosestLeaf); + } +} +A F::m_fn1() const { const_cast(this)->d_ptr->m_fn1(); }