From patchwork Mon Dec 14 18:08:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 556576 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 70BDC140271 for ; Tue, 15 Dec 2015 05:08:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Uole4OaC; dkim-atps=neutral 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=CAA67e2LlQWRoR7vD57eXHIrNbsNbOJ0J7sKD6+/VMIFKlQSop hj2mbE30FDUo6GRMePb3dL7IX7pM4qdb2jk0EwsYXN07JyBG12TQw4Y6MSD4G+dj dDysbnCUhC4b3J/UQcC/2TSq3M9G6DNCvNR5oWtb0F1jZWls6wGNB+0cI= 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=VornYJoa7K1hNLX4GRxvbsaAR/8=; b=Uole4OaC1WQwOqgeWdCc vnn28/iJOw2tTmVQaeZdiOUYZSlgobmqkJnolieCkH6qfF0qihkm8pjhVKZfB5z8 FzZ6Jb0P8Ze7v7Fp8gHUKC/vV++kQ1WsaEoVLq0+BCYYer2Rav30+knuyubR9NaR Sgr15bA2UUmgC2SDSwINv0k= Received: (qmail 33620 invoked by alias); 14 Dec 2015 18:08: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 33605 invoked by uid 89); 14 Dec 2015 18:08: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, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 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 (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 14 Dec 2015 18:08:14 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 75612AAB4; Mon, 14 Dec 2015 18:08:11 +0000 (UTC) Date: Mon, 14 Dec 2015 19:08:11 +0100 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PR 68851] Do not collect thunks in callect_callers Message-ID: <20151214180811.GG3956@virgil.suse.cz> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, in PR 68851, IPA-CP decides to clone for all known contexts, even when it is not local because the code is not supposed to grow anyway. The code doing that uses collect_callers method of cgraph_edge to find all the edges which are to be redirected in such case. However, there is also an edge from a hunk to the cloned node and that gets collected and redirected too. Later on, this inconsistency (a thunk calling a wrong node) leads to an assert in comdat handling, but it can lead to all sorts of trouble. The following patch fixes it by checking that thunks are not added into the vector in that method (which is only used by IPA-CP at this one spot and IPA-SRA so it should be fine). Bootstrapped and tested on x86_64-linux. OK for trunk? And perhaps for the gcc-5 branch too? Thanks, Martin 2015-12-14 Martin Jambor PR ipa/68851 * cgraph.c (collect_callers_of_node_1): Do not collect thunks. * cgraph.h (cgraph_node): Change comment of collect_callers. testsuite/ * g++.dg/ipa/pr68851.C: New test. --- gcc/cgraph.c | 3 ++- gcc/cgraph.h | 2 +- gcc/testsuite/g++.dg/ipa/pr68851.C | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr68851.C diff --git a/gcc/cgraph.c b/gcc/cgraph.c index c8c3370..5a9c2a2 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -2592,7 +2592,8 @@ collect_callers_of_node_1 (cgraph_node *node, void *data) if (avail > AVAIL_INTERPOSABLE) for (cs = node->callers; cs != NULL; cs = cs->next_caller) - if (!cs->indirect_inlining_edge) + if (!cs->indirect_inlining_edge + && !cs->caller->thunk.thunk_p) redirect_callers->safe_push (cs); return false; } diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 0a09391..ba14215 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1070,7 +1070,7 @@ public: cgraph_edge *get_edge (gimple *call_stmt); /* Collect all callers of cgraph_node and its aliases that are known to lead - to NODE (i.e. are not overwritable). */ + to NODE (i.e. are not overwritable) and that are not thunks. */ vec collect_callers (void); /* Remove all callers from the node. */ diff --git a/gcc/testsuite/g++.dg/ipa/pr68851.C b/gcc/testsuite/g++.dg/ipa/pr68851.C new file mode 100644 index 0000000..659e4cd --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr68851.C @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-O3" } + +class A; +class B { +public: + operator A *() const; +}; +class A { +public: + virtual bool isFormControlElement() const {} +}; +class C { + struct D { + B element; + }; + bool checkPseudoClass(const D &, int &) const; +}; +class F { + virtual bool isFormControlElement() const; +}; +class G : A, F { + bool isFormControlElement() const {} +}; +bool C::checkPseudoClass(const D &p1, int &) const { + A &a = *p1.element; + a.isFormControlElement(); + a.isFormControlElement() || a.isFormControlElement(); +}