From patchwork Wed Nov 13 14:16:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1194287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513251-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="I9vRNP4u"; 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 47CmrY5MHyz9sPJ for ; Thu, 14 Nov 2019 01:16:43 +1100 (AEDT) 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=NlxpTTb9cI7R5hRmZX5Uev3UIHKABU/rGfWztWOB+erEv7WkqI 4LxU9vQrlC+Ni8uv2CXtnYb8R6QEGOD0/eicFxxoI5xCDc0KUpPXLw4Nw26v65ZX tTKp1vibYvHlYUOyoAGDTmmQ9dYzk+yUEr4R+aq/z+pWYK7ahx+Ggevag= 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=IjCzzLrH4pOfwXSE2WFKJ5sPIdI=; b=I9vRNP4uYxT8lFRMLq2t t+2LUO/RY5Catnz8oYmui6AhrEaW+k3oWxZOPd+JOklH13gIfg3RP1YoAjNUsOOm yZcJ8SAehY6AmR8h+kto2Bdf+mUnpDbKyRGvITob1ZPktNO3xhXarpdCOmObWkBT Q1+nXlAP2Fbn7kk+7EBfCKw= Received: (qmail 83322 invoked by alias); 13 Nov 2019 14:16:36 -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 83314 invoked by uid 89); 13 Nov 2019 14:16:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 14:16:35 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E5BBCAD79 for ; Wed, 13 Nov 2019 14:16:32 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Subject: [committed] Add a few missing checks that IPA_NODE_REF is not NULL (PR 92454) User-Agent: Notmuch/0.29.1 (https://notmuchmail.org) Emacs/26.3 (x86_64-suse-linux-gnu) Date: Wed, 13 Nov 2019 15:16:32 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, since IPA_NODE_REF does not create summaries now, IPA-CP's spread_undeadness can attempt to dereference a NULL one when a thunk is a part of an SCC in the call graph (because of speculative devirtualization edges). Fixed with checking that is not the case. Bootstrapped and tested on x86_64-linux and and committed because three fourths of the patch are from Honza's Bugzilla comment anyway. Thanks, Martin 2019-11-13 Jan Hubicka Martin Jambor PR ipa/92454 * ipa-cp.c (spread_undeadness): Check that IPA_NODE_REF exists. (identify_dead_nodes): Likewise. testsuite/ * g++.dg/ipa/pr92454.C: New test. --- gcc/ipa-cp.c | 7 +++--- gcc/testsuite/g++.dg/ipa/pr92454.C | 38 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr92454.C diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index b1d899976e8..594cddc5959 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -4971,7 +4971,7 @@ spread_undeadness (struct cgraph_node *node) callee = cs->callee->function_symbol (NULL); info = IPA_NODE_REF (callee); - if (info->node_dead) + if (info && info->node_dead) { info->node_dead = 0; spread_undeadness (callee); @@ -5009,18 +5009,19 @@ identify_dead_nodes (struct cgraph_node *node) struct cgraph_node *v; for (v = node; v; v = ((struct ipa_dfs_info *) v->aux)->next_cycle) if (v->local + && IPA_NODE_REF (v) && !v->call_for_symbol_thunks_and_aliases (has_undead_caller_from_outside_scc_p, NULL, true)) IPA_NODE_REF (v)->node_dead = 1; for (v = node; v; v = ((struct ipa_dfs_info *) v->aux)->next_cycle) - if (!IPA_NODE_REF (v)->node_dead) + if (IPA_NODE_REF (v) && !IPA_NODE_REF (v)->node_dead) spread_undeadness (v); if (dump_file && (dump_flags & TDF_DETAILS)) { for (v = node; v; v = ((struct ipa_dfs_info *) v->aux)->next_cycle) - if (IPA_NODE_REF (v)->node_dead) + if (IPA_NODE_REF (v) && IPA_NODE_REF (v)->node_dead) fprintf (dump_file, " Marking node as dead: %s.\n", v->dump_name ()); } } diff --git a/gcc/testsuite/g++.dg/ipa/pr92454.C b/gcc/testsuite/g++.dg/ipa/pr92454.C new file mode 100644 index 00000000000..de67c66aed0 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr92454.C @@ -0,0 +1,38 @@ +/* Originally PR ipa/91969, options adjusted for PR ipa/92454 */ +/* { dg-options "-O3 --param ipa-cp-eval-threshold=1" } */ + +enum by +{ +}; +class A +{ +public: + class B + { + public: + virtual void m_fn2 (by) = 0; + }; + virtual int m_fn1 (); + B *cf; +}; +by a; +class C : A, A::B +{ + void m_fn2 (by); +}; +void C::m_fn2 (by) { cf->m_fn2 (a); } + +struct a +{ + virtual ~a (); +}; + +struct b +{ + virtual void d (...); +}; + +struct c : a, b +{ + void d (...) {} +};