From patchwork Wed Aug 14 11:15:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1146985 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-506929-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="sH9e3+xa"; 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 467p2W0SSDz9s3Z for ; Wed, 14 Aug 2019 21:56:18 +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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:mime-version :content-type; q=dns; s=default; b=xNBZ4A0ILlFoZe23bu3w4rVEwa30B +d4RAk1r32JQgUsPtwY5ys/hLg3MSsu5nz2GzGnYBBbDcFlQsFEVNAEwBYPplLWh nxhV94TJiVBWGVODAJ7SWk0iLg1+QSJHhLk+klqwjDFv+p3lbsxpEhkDh20H/nUT q+M+w+TCjd+cVY= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:mime-version :content-type; s=default; bh=OivIePqaCVN8RqIoYWJDqIZbiEs=; b=sH9 e3+xavjsrdIlcB73MrEx5cfPYpwrUQmy1B5hKV0u+bS7JuXaEnB8gNyGnlU14ZRc K9jVy4Uz1q29Pwox4EpUQ6rdFYjNrRg+LuBTt5YCc9SppqGxUGbq/8SkzWzWXCxD 2jqYT/jiM5+k9hdH0gEBihhnvKAF9dGZBip47FAw= Received: (qmail 70903 invoked by alias); 14 Aug 2019 11:56:00 -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 70866 invoked by uid 89); 14 Aug 2019 11:56:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 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=HX-Languages-Length:975 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, 14 Aug 2019 11:55:50 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CE17BACEC for ; Wed, 14 Aug 2019 11:55:47 +0000 (UTC) Resent-From: =?utf-8?q?Martin_Li=C5=A1ka?= Resent-To: GCC Patches Resent-Date: Wed, 14 Aug 2019 13:55:47 +0200 Resent-Message-ID: Message-Id: <78a42e1a2102e60a6dd107a090028e9d2db45d7a.1565783608.git.mliska@suse.cz> In-Reply-To: References: From: Martin Liska Date: Wed, 14 Aug 2019 13:15:57 +0200 Subject: [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested. To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 X-IsSubscribed: yes gcc/ChangeLog: 2019-08-14 Martin Liska * cgraph.c (cgraph_node::verify_node): Verify origin, nested and next_nested. --- gcc/cgraph.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index ed46d81a513..eb38b905879 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3464,6 +3464,30 @@ cgraph_node::verify_node (void) e->aux = 0; } } + + if (nested != NULL) + { + for (cgraph_node *n = nested; n != NULL; n = n->next_nested) + { + if (n->origin == NULL) + { + error ("missing origin for a node in a nested list"); + error_found = true; + } + else if (n->origin != this) + { + error ("origin points to a different parent"); + error_found = true; + break; + } + } + } + if (next_nested != NULL && origin == NULL) + { + error ("missing origin for a node in a nested list"); + error_found = true; + } + if (error_found) { dump (stderr); From patchwork Wed Aug 14 11:17:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1146986 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-506930-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="dDOOaEi/"; 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 467p2k2GGtz9s3Z for ; Wed, 14 Aug 2019 21:56:30 +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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:mime-version :content-type; q=dns; s=default; b=Lr5jBRYeUb2CGJ2w/rr7/qu026z14 gxuE0ivVKCxBrsUVrDhwUXiw4IFrJbhCOhct7erFFN1zb5zcCyefaKBD2D9mMob4 1o5JxKE1tMDNHKYNK7Oh03WL2OYv1tlam57Vkj4jiDSw6CGCoOBOoW8sV4QC1rt1 ddRHvDe+t2ZOXE= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:mime-version :content-type; s=default; bh=LsDmNX0fBx9ZtCvM/EKjxvidFn4=; b=dDO OaEi/a7GP68027F1fEmNHE/V1msaEQDrEvLqAIReb95lOklm1Zj46Q6OAM+ZypXT X8z82+BWi2u6T++kRUaHFPgY8c3wMFst0u/niQbQklpKz5kE+EaHhi2EluAJmnpj 0I2DopZ5EsAGvDV3mRgaFoR5WioU2ibccCGgmqEY= Received: (qmail 70921 invoked by alias); 14 Aug 2019 11:56:00 -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 70867 invoked by uid 89); 14 Aug 2019 11:56:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 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, 14 Aug 2019 11:55:50 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CCA09AC6E for ; Wed, 14 Aug 2019 11:55:47 +0000 (UTC) Resent-From: =?utf-8?q?Martin_Li=C5=A1ka?= Resent-To: GCC Patches Resent-Date: Wed, 14 Aug 2019 13:55:47 +0200 Resent-Message-ID: <48656d3a-3419-7268-9d7f-31c1550138b8@suse.cz> Message-Id: <2e51950cd70703be3d9aa65487b94f742f7b7e88.1565783608.git.mliska@suse.cz> In-Reply-To: References: From: Martin Liska Date: Wed, 14 Aug 2019 13:17:22 +0200 Subject: [PATCH 2/2] Clean next_nested properly. To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 X-IsSubscribed: yes gcc/ChangeLog: 2019-08-14 Martin Liska PR ipa/91438 * cgraph.c (cgraph_node::remove): When setting n->origin = NULL for all nested functions, reset also next_nested. --- gcc/cgraph.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index eb38b905879..ea8ab38d806 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1767,8 +1767,6 @@ cgraph_node::release_body (bool keep_arguments) void cgraph_node::remove (void) { - cgraph_node *n; - if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this)) fprintf (symtab->ipa_clones_dump_file, "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), order, @@ -1785,8 +1783,13 @@ cgraph_node::remove (void) */ force_output = false; forced_by_abi = false; - for (n = nested; n; n = n->next_nested) + cgraph_node *next = nested; + for (cgraph_node *n = nested; n; n = next) + { + next = n->next_nested; n->origin = NULL; + n->next_nested = NULL; + } nested = NULL; if (origin) { @@ -1840,7 +1843,7 @@ cgraph_node::remove (void) */ if (symtab->state != LTO_STREAMING) { - n = cgraph_node::get (decl); + cgraph_node *n = cgraph_node::get (decl); if (!n || (!n->clones && !n->clone_of && !n->global.inlined_to && ((symtab->global_info_ready || in_lto_p)