From patchwork Tue Apr 17 06:55:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 899094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476460-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MrY8agzz"; dkim-atps=neutral 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 40QGGm03rSz9ry1 for ; Tue, 17 Apr 2018 16:55:24 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=qUgANIgDbxObB9hS/iFdVRk9CcKloBTCtVkUB8H3DNzq190YB0 +dRdknrKb3t062TejW69n2m4VKAPIFA2cfE2LhEJtJMx8gIHJcqBouqNlIug20mu +iK4tMQh5Mk5Rw95ViHuFYSiwz9lvjVzHpT92YHGlhUSgzUR2bZ54kMdU= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=UrAwDVLKcYNDK9/VqqAH/BEdp6g=; b=MrY8agzzbX988xEDu+DA NlNdo+NwHFV5zUWu+Ht2ogUcZsDWM2kPwID6QV6xJmGomiOlcTGxOPZi9HTUiv9e vvQVstEG1avxTlKtPtOaYm7/HN7M8hfGE5DYTswuSL55y5LsDIyH+sdKtFEpW8IW p5VR/CDB/8plQolomSUaoCU= Received: (qmail 46796 invoked by alias); 17 Apr 2018 06:55:17 -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 46773 invoked by uid 89); 17 Apr 2018 06:55:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=H*UA:https X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Apr 2018 06:55:12 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AD562AE65; Tue, 17 Apr 2018 06:55:09 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Jakub Jelinek Subject: [PR 85421] Call expand_all_artificial_thunks in ipa-cp if necessary User-Agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/25.3.1 (x86_64-suse-linux-gnu) Date: Tue, 17 Apr 2018 08:55:09 +0200 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, my fix from last week caused an ICE described in PR 85421 because I did not read my own comment and forgot that after calls to redirect_callee_duplicating_thunks, one must finish the work by calling expand_all_artificial_thunks, otherwise we end up with unanalyzed thunks and hit some assert sooner or later, like we did in this bug. Fixed with the patch below, bootstrapped, LTO-bootstrapped and tested on x86_64-linux. OK for trunk? I'm sorry for introducing an ICE so late in stage4, Martin 2018-04-17 Martin Jambor PR ipa/85421 * ipa-cp.c (create_specialized_node): Call expand_all_artificial_thunks if necessary. * testsuite/g++.dg/ipa/pr85421.C: New test. 2018-04-08 Martin Jambor --- gcc/ipa-cp.c | 3 + gcc/testsuite/g++.dg/ipa/pr85421.C | 131 +++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/pr85421.C diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index b2627ffd05f..4e0e20af409 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -3863,6 +3863,7 @@ create_specialized_node (struct cgraph_node *node, new_node = node->create_virtual_clone (callers, replace_trees, args_to_skip, "constprop"); + bool have_self_recursive_calls = !self_recursive_calls.is_empty (); for (unsigned j = 0; j < self_recursive_calls.length (); j++) { cgraph_edge *cs = next_edge_clone[self_recursive_calls[j]->uid]; @@ -3870,6 +3871,8 @@ create_specialized_node (struct cgraph_node *node, gcc_assert (cs->caller == new_node); cs->redirect_callee_duplicating_thunks (new_node); } + if (have_self_recursive_calls) + new_node->expand_all_artificial_thunks (); ipa_set_node_agg_value_chain (new_node, aggvals); for (av = aggvals; av; av = av->next) diff --git a/gcc/testsuite/g++.dg/ipa/pr85421.C b/gcc/testsuite/g++.dg/ipa/pr85421.C new file mode 100644 index 00000000000..517d99ae8f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr85421.C @@ -0,0 +1,131 @@ +// { dg-do compile } +// { dg-options "-O3 -std=gnu++1y -w" } + +namespace { +template b c(b); +template class> struct f { + using g = d; +}; +template class aa> using h = f; +template class aa> +using i = typename h::g; +template struct j { typedef b k; }; +} // namespace +namespace l { +template class m { +public: + typedef b k; +}; +} // namespace l +namespace a { +template using n = l::m; +template class ac : public n {}; +struct s { + template using ad = typename b::e; +}; +template struct p : s { + typedef typename o::k k; + using ag = i; +}; +} // namespace a +namespace l { +template struct t : a::p {}; +} // namespace l +namespace a { +template struct al { + template static void an(am ao, am) { c(*ao); } +}; +template void aq(am ao, am ap) { + typedef typename j::k ar; + al<__has_trivial_destructor(ar)>::an(ao, ap); +} +namespace { +typedef char au; +} +} // namespace a +typedef char av; +typedef int aw; +typedef av ay; +typedef aw az; +namespace a { +template struct ba { + typedef typename l::t::ag ag; + struct { + ag bb; + ag bc; + } bd; +}; +template > class be : ba { + typedef ba bf; + typedef typename bf::ag ag; + +public: + void bh() { bi(this->bd.bb); } + void bi(ag bj) { aq(bj, this->bd.bc); } +}; +} // namespace a +namespace bk { +enum bl {}; +enum bn { bo }; +class q { +public: + static a::au bp(bn); + static bool bq(a::au *br, bn g) { return bs(br, g); } + static bl bs(a::au *br, bn g) { + if (br) { + auto bt = bp(g); + if (bt) + return bl(); + } + } +}; +template class bu {}; +} // namespace bk +namespace bv { +namespace bw { +class bx; +} +} // namespace bv +namespace bk { +enum by { bz }; +struct ca; +class cb { +public: + class cc { + public: + virtual void cd(by) = 0; + }; + virtual bu e(); + cc *cf; +}; +class cg { +public: + ~cg() { q::bq(ch, bo); } + a::au *ch; +}; +class ci { + cg cj; +}; +namespace ck { +enum cl : ay; +} +class r : ci {}; +class cn { +public: + ck::cl co(); +}; +by cp(ck::cl); +class cq : cb, cb::cc { + bu ce(bv::bw::bx &, az) noexcept; + void cd(by); + void cr(bv::bw::bx &, az, cb::cc *) noexcept; + cn cs; + a::be ct; +}; +} // namespace bk +using bv::bw::bx; +namespace bk { +bu cq::ce(bx &, az) noexcept { ct.bh(); } +void cq::cr(bx &, az, cb::cc *) noexcept { cd(bz); } +void cq::cd(by) { cf->cd(cp(cs.co())); } +} // namespace bk